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)
|
# v1.0.7 (pre-release)
|
||||||
- Ignore chapter markers and single newlines when calculating text length.
|
- 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.
|
- Added "Playing..." indicator for "Preview" button in the voice mixer.
|
||||||
|
|
||||||
# v1.0.6
|
# v1.0.6
|
||||||
|
|||||||
@@ -511,6 +511,32 @@ class ConversionThread(QThread):
|
|||||||
chapter_out_path = os.path.join(
|
chapter_out_path = os.path.join(
|
||||||
chapters_out_dir, f"{chapter_filename}.{chapter_ext}"
|
chapters_out_dir, f"{chapter_filename}.{chapter_ext}"
|
||||||
)
|
)
|
||||||
|
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(
|
sf.write(
|
||||||
chapter_out_path,
|
chapter_out_path,
|
||||||
chapter_audio,
|
chapter_audio,
|
||||||
@@ -571,6 +597,32 @@ class ConversionThread(QThread):
|
|||||||
out_path = os.path.splitext(out_path)[0] + ".wav"
|
out_path = os.path.splitext(out_path)[0] + ".wav"
|
||||||
self.output_format = "wav"
|
self.output_format = "wav"
|
||||||
m4b_picked = True
|
m4b_picked = True
|
||||||
|
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)
|
sf.write(out_path, audio, 24000, format=self.output_format)
|
||||||
if m4b_picked:
|
if m4b_picked:
|
||||||
out_path = self._generate_m4b_with_chapters(out_path, chapters_time)
|
out_path = self._generate_m4b_with_chapters(out_path, chapters_time)
|
||||||
|
|||||||
@@ -695,6 +695,7 @@ class abogen(QWidget):
|
|||||||
("wav", "wav"),
|
("wav", "wav"),
|
||||||
("flac", "flac"),
|
("flac", "flac"),
|
||||||
("mp3", "mp3"),
|
("mp3", "mp3"),
|
||||||
|
("opus", "opus (best)"),
|
||||||
("m4b", "m4b (with chapters)"),
|
("m4b", "m4b (with chapters)"),
|
||||||
]:
|
]:
|
||||||
self.format_combo.addItem(label, key)
|
self.format_combo.addItem(label, key)
|
||||||
|
|||||||
Reference in New Issue
Block a user