forked from zhouliangyuan/AI-Vtuber
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db53421
commit ff8a5af
Showing
7 changed files
with
152 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import json, logging, asyncio | ||
import aiohttp, requests, ssl | ||
from urllib.parse import urlencode | ||
import traceback | ||
from urllib.parse import urljoin | ||
|
||
async def clone_voice_api(text): | ||
url = 'http://127.0.0.1:9988/tts' | ||
|
||
# voice=cn-nan.wav&text=%E4%BD%A0%E5%A5%BD&language=zh-cn&speed=1 | ||
params = { | ||
"voice": "cn-nan.wav", | ||
"language": "zh-cn", | ||
'speed': 1, | ||
'text': text | ||
} | ||
|
||
print(f"params={params}") | ||
|
||
try: | ||
async with aiohttp.ClientSession() as session: | ||
async with session.post(url, data=params) as response: | ||
ret = await response.json() | ||
print(ret) | ||
|
||
file_path = ret["filename"] | ||
|
||
return file_path | ||
|
||
except aiohttp.ClientError as e: | ||
logging.error(traceback.format_exc()) | ||
logging.error(f'clone_voice请求失败: {e}') | ||
except Exception as e: | ||
logging.error(traceback.format_exc()) | ||
logging.error(f'clone_voice未知错误: {e}') | ||
|
||
return None | ||
|
||
|
||
asyncio.run(clone_voice_api("你好")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters