-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(examples): use mp3 output by default (#449)
- Loading branch information
Showing
10 changed files
with
63 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,3 +169,4 @@ cython_debug/ | |
|
||
# inferred result | ||
*.wav | ||
*.mp3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from .np import unsafe_float_to_int16 | ||
from .av import wav2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from io import BufferedWriter, BytesIO | ||
from typing import Dict | ||
|
||
import av | ||
|
||
|
||
video_format_dict: Dict[str, str] = { | ||
"m4a": "mp4", | ||
} | ||
|
||
audio_format_dict: Dict[str, str] = { | ||
"ogg": "libvorbis", | ||
"mp4": "aac", | ||
} | ||
|
||
|
||
def wav2(i: BytesIO, o: BufferedWriter, format: str): | ||
""" | ||
https://github.com/fumiama/Retrieval-based-Voice-Conversion-WebUI/blob/412a9950a1e371a018c381d1bfb8579c4b0de329/infer/lib/audio.py#L20 | ||
""" | ||
inp = av.open(i, "r") | ||
format = video_format_dict.get(format, format) | ||
out = av.open(o, "w", format=format) | ||
format = audio_format_dict.get(format, format) | ||
|
||
ostream = out.add_stream(format) | ||
|
||
for frame in inp.decode(audio=0): | ||
for p in ostream.encode(frame): | ||
out.mux(p) | ||
|
||
for p in ostream.encode(None): | ||
out.mux(p) | ||
|
||
out.close() | ||
inp.close() |