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
e3116a78c7
commit
0a731774d1
1 changed files with 18 additions and 18 deletions
|
|
@ -47,26 +47,26 @@ class TTSProvider(TTSProviderBase):
|
||||||
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)))
|
||||||
|
|
||||||
# def yield_data(self,url,params,headers):
|
def yield_data(self,url,params,headers):
|
||||||
# response = requests.get(url=url, headers=headers, params=params, stream=True)
|
response = requests.get(url=url, headers=headers, params=params, stream=True)
|
||||||
# if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
# for chunk in response.iter_content(chunk_size=None):
|
for chunk in response.iter_content(chunk_size=None):
|
||||||
# if chunk:
|
if chunk:
|
||||||
# yield chunk
|
yield chunk
|
||||||
# else:
|
else:
|
||||||
# print(f"请求失败,状态码: {response.status_code}")
|
print(f"请求失败,状态码: {response.status_code}")
|
||||||
# print(f"错误信息: {response.text}")
|
print(f"错误信息: {response.text}")
|
||||||
|
|
||||||
|
|
||||||
async def yield_data(self,base_url:str='',params:dict={},headers:dict={}):
|
# async def yield_data(self,base_url:str='',params:dict={},headers:dict={}):
|
||||||
async with aiohttp.ClientSession() as session:
|
# async with aiohttp.ClientSession() as session:
|
||||||
try:
|
# try:
|
||||||
async with session.get(base_url, params=params, headers=headers,timeout=10) as response:
|
# async with session.get(base_url, params=params, headers=headers,timeout=10) as response:
|
||||||
if response.status == 200:
|
# if response.status == 200:
|
||||||
async for r in response.content.iter_chunks():
|
# async for r in response.content.iter_chunks():
|
||||||
yield r[0]
|
# yield r[0]
|
||||||
except aiohttp.ClientError as e:
|
# except aiohttp.ClientError as e:
|
||||||
pass
|
# pass
|
||||||
|
|
||||||
def double_stream(self,question:str='',device_id:str=''):
|
def double_stream(self,question:str='',device_id:str=''):
|
||||||
params = {
|
params = {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue