未验证 提交 2ae0f66d 编写于 作者: Z zhoupc2015 提交者: GitHub

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
上级 99551e56
......@@ -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.")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册