mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
add
This commit is contained in:
parent
6fa047c07d
commit
be4f546a9c
2 changed files with 14 additions and 0 deletions
|
|
@ -36,6 +36,8 @@ async def sendAudio(conn, audios):
|
||||||
if isinstance(audios,types.GeneratorType):
|
if isinstance(audios,types.GeneratorType):
|
||||||
count = 0
|
count = 0
|
||||||
for opus_packet in audios:
|
for opus_packet in audios:
|
||||||
|
if len(opus_packet) < 1:
|
||||||
|
continue
|
||||||
if count < 3:
|
if count < 3:
|
||||||
await conn.websocket.send(opus_packet)
|
await conn.websocket.send(opus_packet)
|
||||||
conn.logger.bind(tag=TAG).debug(f"预缓冲帧 {count}, 时间: {(time.perf_counter() - start_time) * 1000:.2f}ms")
|
conn.logger.bind(tag=TAG).debug(f"预缓冲帧 {count}, 时间: {(time.perf_counter() - start_time) * 1000:.2f}ms")
|
||||||
|
|
|
||||||
|
|
@ -112,4 +112,16 @@ class TTSProvider(TTSProviderBase):
|
||||||
|
|
||||||
return opus_datas, duration
|
return opus_datas, duration
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
config = {'access_token':'123',
|
||||||
|
'voice':'OUeAo1mhq6IBExi',
|
||||||
|
'response_format':'opus',
|
||||||
|
'sample_rate':16000
|
||||||
|
}
|
||||||
|
tts_provider = TTSProvider(config=config,delete_audio_file=True)
|
||||||
|
tts_provider.text_to_speak('你好呀,你是谁','asdf.txt')
|
||||||
|
data,dur = tts_provider.audio_to_opus_data('asdf.txt')
|
||||||
|
for x in data:
|
||||||
|
print(len(x))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue