mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 13:40:27 +02:00
Added .opus support as output format for generated audio files.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# v1.0.7 (pre-release)
|
||||
- Ignore chapter markers and single newlines when calculating text length.
|
||||
- Added `.opus` support as output format for generated audio files.
|
||||
- Added "Playing..." indicator for "Preview" button in the voice mixer.
|
||||
|
||||
# v1.0.6
|
||||
|
||||
+59
-7
@@ -511,12 +511,38 @@ class ConversionThread(QThread):
|
||||
chapter_out_path = os.path.join(
|
||||
chapters_out_dir, f"{chapter_filename}.{chapter_ext}"
|
||||
)
|
||||
sf.write(
|
||||
chapter_out_path,
|
||||
chapter_audio,
|
||||
24000,
|
||||
format=chapter_format,
|
||||
)
|
||||
if self.output_format == "opus":
|
||||
static_ffmpeg.add_paths()
|
||||
proc = subprocess.Popen(
|
||||
[
|
||||
"ffmpeg",
|
||||
"-y",
|
||||
"-f",
|
||||
"f32le",
|
||||
"-ar",
|
||||
"24000",
|
||||
"-ac",
|
||||
"1",
|
||||
"-i",
|
||||
"pipe:",
|
||||
"-c:a",
|
||||
"libopus",
|
||||
"-b:a",
|
||||
"24000",
|
||||
chapter_out_path,
|
||||
],
|
||||
stdin=subprocess.PIPE,
|
||||
)
|
||||
proc.stdin.write(chapter_audio.astype("float32").tobytes())
|
||||
proc.stdin.close()
|
||||
proc.wait()
|
||||
else:
|
||||
sf.write(
|
||||
chapter_out_path,
|
||||
chapter_audio,
|
||||
24000,
|
||||
format=chapter_format,
|
||||
)
|
||||
|
||||
# Generate .srt subtitle file for chapter if not Disabled
|
||||
if self.subtitle_mode != "Disabled" and chapter_subtitle_entries:
|
||||
@@ -571,7 +597,33 @@ class ConversionThread(QThread):
|
||||
out_path = os.path.splitext(out_path)[0] + ".wav"
|
||||
self.output_format = "wav"
|
||||
m4b_picked = True
|
||||
sf.write(out_path, audio, 24000, format=self.output_format)
|
||||
if self.output_format == "opus":
|
||||
static_ffmpeg.add_paths()
|
||||
proc = subprocess.Popen(
|
||||
[
|
||||
"ffmpeg",
|
||||
"-y",
|
||||
"-f",
|
||||
"f32le",
|
||||
"-ar",
|
||||
"24000",
|
||||
"-ac",
|
||||
"1",
|
||||
"-i",
|
||||
"pipe:",
|
||||
"-c:a",
|
||||
"libopus",
|
||||
"-b:a",
|
||||
"24000",
|
||||
out_path,
|
||||
],
|
||||
stdin=subprocess.PIPE,
|
||||
)
|
||||
proc.stdin.write(audio.astype("float32").tobytes())
|
||||
proc.stdin.close()
|
||||
proc.wait()
|
||||
else:
|
||||
sf.write(out_path, audio, 24000, format=self.output_format)
|
||||
if m4b_picked:
|
||||
out_path = self._generate_m4b_with_chapters(out_path, chapters_time)
|
||||
|
||||
|
||||
@@ -695,6 +695,7 @@ class abogen(QWidget):
|
||||
("wav", "wav"),
|
||||
("flac", "flac"),
|
||||
("mp3", "mp3"),
|
||||
("opus", "opus (best)"),
|
||||
("m4b", "m4b (with chapters)"),
|
||||
]:
|
||||
self.format_combo.addItem(label, key)
|
||||
|
||||
Reference in New Issue
Block a user