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
b4a9d368d0
commit
a11126361a
1 changed files with 14 additions and 2 deletions
|
|
@ -12,6 +12,7 @@ import numpy as np
|
||||||
class TTSProvider(TTSProviderBase):
|
class TTSProvider(TTSProviderBase):
|
||||||
def __init__(self, config, delete_audio_file):
|
def __init__(self, config, delete_audio_file):
|
||||||
super().__init__(config, delete_audio_file)
|
super().__init__(config, delete_audio_file)
|
||||||
|
self.provider_name ='linkerai'
|
||||||
self.access_token = config.get("access_token")
|
self.access_token = config.get("access_token")
|
||||||
self.voice = config.get("voice")
|
self.voice = config.get("voice")
|
||||||
self.response_format = config.get("response_format")
|
self.response_format = config.get("response_format")
|
||||||
|
|
@ -43,9 +44,7 @@ class TTSProvider(TTSProviderBase):
|
||||||
f.write('http_post\n')
|
f.write('http_post\n')
|
||||||
f.write('%s\n'%(json.dumps(params,ensure_ascii=False)))
|
f.write('%s\n'%(json.dumps(params,ensure_ascii=False)))
|
||||||
f.write('%s'%(json.dumps(headers,ensure_ascii=False)))
|
f.write('%s'%(json.dumps(headers,ensure_ascii=False)))
|
||||||
self.cache_queue.append(output_file)
|
|
||||||
|
|
||||||
|
|
||||||
def yield_data(self,params,headers):
|
def yield_data(self,params,headers):
|
||||||
response = requests.get(self.api_url, headers=headers, params=params, stream=True)
|
response = requests.get(self.api_url, headers=headers, params=params, stream=True)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
|
|
@ -55,6 +54,19 @@ class TTSProvider(TTSProviderBase):
|
||||||
else:
|
else:
|
||||||
print(f"请求失败,状态码: {response.status_code}")
|
print(f"请求失败,状态码: {response.status_code}")
|
||||||
print(f"错误信息: {response.text}")
|
print(f"错误信息: {response.text}")
|
||||||
|
def double_stream(self,question:str='',device_id:str=''):
|
||||||
|
params = {
|
||||||
|
"question": question,
|
||||||
|
"device_id": device_id,
|
||||||
|
"instruct_text": self.instruct_text,
|
||||||
|
"audio_format": 'opus'
|
||||||
|
}
|
||||||
|
headers = {
|
||||||
|
"Authorization": f"Bearer {self.access_token}",
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
return self.yield_data(params=params,headers=headers)
|
||||||
|
|
||||||
|
|
||||||
def audio_to_opus_data(self, audio_file_path):
|
def audio_to_opus_data(self, audio_file_path):
|
||||||
data = b''
|
data = b''
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue