Solve "unknown format: 3" (#2422)

* Solve execute the following code with return  wav:
iob = io.BytesIO(wav)
wave.open(iob, 'rb')
will throw an "unknown format: 3"  exception
pull/2429/head
zhoupc2015 2 years ago committed by GitHub
parent 99551e5686
commit 2ae0f66d0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -22,7 +22,6 @@ import librosa
import numpy as np
import paddle
import soundfile as sf
from scipy.io import wavfile
from paddlespeech.cli.log import logger
from paddlespeech.cli.tts.infer import TTSExecutor
@ -409,7 +408,8 @@ class PaddleTTSConnectionHandler(TTSServerExecutor):
# wav to base64
buf = io.BytesIO()
wavfile.write(buf, target_fs, wav_speed)
sf.write(buf, wav_speed, target_fs, format="wav")
buf.seek(0)
base64_bytes = base64.b64encode(buf.read())
wav_base64 = base64_bytes.decode('utf-8')
logger.debug("Audio to string successfully.")

@ -20,7 +20,6 @@ import librosa
import numpy as np
import paddle
import soundfile as sf
from scipy.io import wavfile
from paddlespeech.cli.log import logger
from paddlespeech.cli.tts.infer import TTSExecutor
@ -173,7 +172,9 @@ class PaddleTTSConnectionHandler(TTSServerExecutor):
# wav to base64
buf = io.BytesIO()
wavfile.write(buf, target_fs, wav_speed)
sf.write(buf, wav_speed, target_fs, format="wav")
buf.seek(0)
base64_bytes = base64.b64encode(buf.read())
wav_base64 = base64_bytes.decode('utf-8')
logger.debug("Audio to string successfully.")

Loading…
Cancel
Save