feat(voice): switch TTS to Seed 2.0 uranus voices
Use classic male/female and sunny-sweet speakers with seed-tts-2.0 resource id.
This commit is contained in:
+19
-7
@@ -5,24 +5,36 @@ import json
|
||||
import uuid
|
||||
from pathlib import Path
|
||||
|
||||
_RESOURCE_ID = "volc.service_type.10029"
|
||||
# TTS 1.0 (moon/mars) vs 2.0 (uranus / ICL_uranus)
|
||||
_RESOURCE_TTS_1 = "volc.service_type.10029"
|
||||
_RESOURCE_TTS_2 = "seed-tts-2.0"
|
||||
_ENDPOINT = "wss://openspeech.bytedance.com/api/v3/tts/unidirectional/stream"
|
||||
|
||||
# Product labels: 经典男声 / 经典女声 / 阳光甜妹
|
||||
_VOICE_CHOICES = [
|
||||
"zh_female_cancan_mars_bigtts",
|
||||
"zh_female_shuangkuaisisi_moon_bigtts",
|
||||
"zh_male_wennuanahu_moon_bigtts",
|
||||
"zh_male_sunwukong_moon_bigtts",
|
||||
"zh_male_m191_uranus_bigtts",
|
||||
"zh_female_xiaohe_uranus_bigtts",
|
||||
"ICL_uranus_zh_female_yuanqitianmei_tob",
|
||||
]
|
||||
|
||||
_DEFAULT_VOICE = "zh_female_xiaohe_uranus_bigtts"
|
||||
|
||||
_FORMAT_CHOICES = ["mp3", "wav", "pcm"]
|
||||
|
||||
|
||||
def resource_id_for_speaker(speaker: str) -> str:
|
||||
"""Pick Volcengine resource id for a speaker."""
|
||||
s = speaker or ""
|
||||
if "uranus" in s or s.startswith("ICL_uranus_"):
|
||||
return _RESOURCE_TTS_2
|
||||
return _RESOURCE_TTS_1
|
||||
|
||||
|
||||
def synthesize_tts(
|
||||
appid: str,
|
||||
token: str,
|
||||
text: str,
|
||||
speaker: str = "zh_male_wennuanahu_moon_bigtts",
|
||||
speaker: str = _DEFAULT_VOICE,
|
||||
fmt: str = "mp3",
|
||||
speech_rate: int = 0,
|
||||
output_path: str = "output.mp3",
|
||||
@@ -42,7 +54,7 @@ def synthesize_tts(
|
||||
headers = {
|
||||
"X-Api-App-Id": appid,
|
||||
"X-Api-Access-Key": token,
|
||||
"X-Api-Resource-Id": _RESOURCE_ID,
|
||||
"X-Api-Resource-Id": resource_id_for_speaker(speaker),
|
||||
"X-Api-Connect-Id": str(uuid.uuid4()),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user