mirror of
https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git
synced 2026-01-20 11:00:23 +00:00
Format code (#1193)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
72a18e66b6
commit
a6456f6d46
@@ -3,38 +3,49 @@ import numpy as np
|
||||
import av
|
||||
from io import BytesIO
|
||||
|
||||
|
||||
def wav2(i, o, format):
|
||||
inp = av.open(i, 'rb')
|
||||
if format == "m4a": format = "mp4"
|
||||
out = av.open(o, 'wb', format=format)
|
||||
if format == "ogg": format = "libvorbis"
|
||||
if format == "mp4": format = "aac"
|
||||
inp = av.open(i, "rb")
|
||||
if format == "m4a":
|
||||
format = "mp4"
|
||||
out = av.open(o, "wb", format=format)
|
||||
if format == "ogg":
|
||||
format = "libvorbis"
|
||||
if format == "mp4":
|
||||
format = "aac"
|
||||
|
||||
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(frame):
|
||||
out.mux(p)
|
||||
|
||||
for p in ostream.encode(None): out.mux(p)
|
||||
for p in ostream.encode(None):
|
||||
out.mux(p)
|
||||
|
||||
out.close()
|
||||
inp.close()
|
||||
|
||||
|
||||
def audio2(i, o, format, sr):
|
||||
inp = av.open(i, 'rb')
|
||||
out = av.open(o, 'wb', format=format)
|
||||
if format == "ogg": format = "libvorbis"
|
||||
if format == "f32le": format = "pcm_f32le"
|
||||
inp = av.open(i, "rb")
|
||||
out = av.open(o, "wb", format=format)
|
||||
if format == "ogg":
|
||||
format = "libvorbis"
|
||||
if format == "f32le":
|
||||
format = "pcm_f32le"
|
||||
|
||||
ostream = out.add_stream(format, channels=1)
|
||||
ostream.sample_rate = sr
|
||||
|
||||
for frame in inp.decode(audio=0):
|
||||
for p in ostream.encode(frame): out.mux(p)
|
||||
for p in ostream.encode(frame):
|
||||
out.mux(p)
|
||||
|
||||
out.close()
|
||||
inp.close()
|
||||
|
||||
|
||||
def load_audio(file, sr):
|
||||
try:
|
||||
file = (
|
||||
|
||||
Reference in New Issue
Block a user