Skip to content

Commit

Permalink
Update: Update TTS model use V2 API
Browse files Browse the repository at this point in the history
  • Loading branch information
whats2000 committed Oct 30, 2024
1 parent b57451b commit 1299b93
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
10 changes: 8 additions & 2 deletions bot/api/tts_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,14 @@ def text_to_speech(text: str, character: str, message: disnake.Message = None) -
POST localhost:9880
Request:
{
"ref_audio_path": "123.wav", // For APIv2
"refer_wav_path": "123.wav",
"prompt_text": "一二三。",
"prompt_lang": "zh", // For APIv2
"prompt_language": "zh",
"text": "先帝创业未半而中道崩殂,今天下三分,益州疲弊,此诚危急存亡之秋也。",
"text_language": "zh"
"text_lang": "zh", // For APIv2
"text_language": "zh",
}
Response:
Expand Down Expand Up @@ -141,11 +144,14 @@ def text_to_speech(text: str, character: str, message: disnake.Message = None) -
try:
logger.info(f"Sending TTS request for chunk: {chunk}")
response = requests.post(config.TTS_API_URL, json={
"ref_audio_path": os.path.join(os.getcwd(), "data", "samples", character_sample["file"]),
"refer_wav_path": os.path.join(os.getcwd(), "data", "samples", character_sample["file"]),
"prompt_text": character_sample["text"],
"prompt_lang": "zh",
"prompt_language": "zh",
"text": chunk,
"text_language": "zh"
"text_language": "zh",
"text_lang": "zh",
})

response.raise_for_status()
Expand Down
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from google.generativeai import GenerationConfig

DISCORD_TOKEN = environ.get('DISCORD_TOKEN')
TTS_API_URL = 'http://127.0.0.1:9880/'
TTS_API_URL = 'http://127.0.0.1:9880/tts/'
GUILD_ID = int(environ.get('GUILD_ID')) if 'GUILD_ID' in environ else 933290709589577728


Expand Down
3 changes: 2 additions & 1 deletion data/game_id_to_user_id.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"monkey_Reachrs": 688181698822799414,
"FlandreLed": 1193230992354312203,
"Zero_One_015645": 866858877928210445,
"BasedSinger5437": 854147624604139521
"BasedSinger5437": 854147624604139521,
"DG2u_": 827887469717749760
}
9 changes: 7 additions & 2 deletions data/user_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"user_settings": {
"495903741354967041": {
"selected_sample": "\u85ff\u85ff",
"tts_enabled": true,
"tts_enabled": false,
"game_id": "whats2000_"
},
"667012201017638913": {
Expand Down Expand Up @@ -78,7 +78,7 @@
"tts_enabled": false
},
"866858877928210445": {
"selected_sample": "\u7518\u96e8",
"selected_sample": "\u85ff\u85ff",
"tts_enabled": true,
"game_id": "Zero_One_015645"
},
Expand All @@ -89,6 +89,11 @@
"game_id": "BasedSinger5437",
"selected_sample": "\u85ff\u85ff",
"tts_enabled": true
},
"827887469717749760": {
"game_id": "DG2u_",
"tts_enabled": true,
"selected_sample": "\u85ff\u85ff"
}
}
}

0 comments on commit 1299b93

Please sign in to comment.