Solve execute the following code with return wav:

iob = io.BytesIO(wav)
wave.open(iob, 'rb')
will throw an "unknown format: 3"  exception
pull/2422/head
zhoupc2015 3 years ago
parent 5e714ecb4a
commit 78a16247c0

@ -409,7 +409,9 @@ class PaddleTTSConnectionHandler(TTSServerExecutor):
# wav to base64 # wav to base64
buf = io.BytesIO() buf = io.BytesIO()
wavfile.write(buf, target_fs, wav_speed) # 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()) base64_bytes = base64.b64encode(buf.read())
wav_base64 = base64_bytes.decode('utf-8') wav_base64 = base64_bytes.decode('utf-8')
logger.debug("Audio to string successfully.") logger.debug("Audio to string successfully.")

@ -173,7 +173,10 @@ class PaddleTTSConnectionHandler(TTSServerExecutor):
# wav to base64 # wav to base64
buf = io.BytesIO() buf = io.BytesIO()
wavfile.write(buf, target_fs, wav_speed) # 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()) base64_bytes = base64.b64encode(buf.read())
wav_base64 = base64_bytes.decode('utf-8') wav_base64 = base64_bytes.decode('utf-8')
logger.debug("Audio to string successfully.") logger.debug("Audio to string successfully.")

Loading…
Cancel
Save