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
80f24645a9
commit
84c6d45af5
1 changed files with 5 additions and 3 deletions
|
|
@ -74,9 +74,11 @@ class TTSProvider(TTSProviderBase):
|
|||
def audio_to_opus_data(self, audio_file_path):
|
||||
data = b''
|
||||
if os.path.exists(audio_file_path):
|
||||
with open(audio_file_path,encoding='utf-8') as f:
|
||||
with open(audio_file_path,'rb') as f:
|
||||
data = f.read(10)
|
||||
if data.startswith('http_post'):
|
||||
if data.startswith(b'http_post'):
|
||||
with open(audio_file_path,encoding='utf-8') as f:
|
||||
_ = f.read(10)
|
||||
duration = 100
|
||||
code = []
|
||||
for line in f.readlines():
|
||||
|
|
@ -85,7 +87,7 @@ class TTSProvider(TTSProviderBase):
|
|||
headers = code[1]
|
||||
return self.yield_data(self.api_url,params=params,headers=headers),duration
|
||||
|
||||
if not data.startswith('http_post'):# 兼容非流式音频播放
|
||||
else: #兼容非流式音频播放
|
||||
f.seek(0)
|
||||
file_type = os.path.splitext(audio_file_path)[1]
|
||||
if file_type:
|
||||
|
|
|
|||
Loading…
Reference in a new issue