from typecast import Typecastfrom typecast.models import TTSRequest, SmartPromptclient = Typecast()response = client.text_to_speech(TTSRequest( text="Everything is going to be okay.", model="ssfm-v30", voice_id="tc_672c5f5ce59fac2a48faeaee", prompt=SmartPrompt( emotion_type="smart", previous_text="I just got the best news!", # 선택적 문맥 next_text="I can't wait to celebrate!" # 선택적 문맥 )))
프리셋 값으로 감정을 명시적으로 설정합니다:
from typecast import Typecastfrom typecast.models import TTSRequest, PresetPromptclient = Typecast()response = client.text_to_speech(TTSRequest( text="I am so excited to show you these features!", model="ssfm-v30", voice_id="tc_672c5f5ce59fac2a48faeaee", prompt=PresetPrompt( emotion_type="preset", emotion_preset="happy", # normal, happy, sad, angry, whisper, toneup, tonedown emotion_intensity=1.5 # 범위: 0.0 ~ 2.0 )))
from typecast import Typecastfrom typecast.models import VoicesV2Filter, TTSModel, GenderEnum, AgeEnumclient = Typecast()# 모든 음성 가져오기voices = client.voices_v2()# 기준으로 필터링filtered = client.voices_v2(VoicesV2Filter( model=TTSModel.SSFM_V30, gender=GenderEnum.FEMALE, age=AgeEnum.YOUNG_ADULT))# 음성 정보 표시for voice in voices: print(f"ID: {voice.voice_id}, Name: {voice.voice_name}") print(f"Gender: {voice.gender}, Age: {voice.age}") print(f"Models: {', '.join(m.version.value for m in voice.models)}") print(f"Use cases: {voice.use_cases}")
from typecast import Typecastfrom typecast.models import TTSRequestWithTimestampsclient = Typecast(api_key="YOUR_API_KEY")result = client.text_to_speech_with_timestamps(TTSRequestWithTimestamps( text="Hello. How are you?", model="ssfm-v30", voice_id="tc_60e5426de8b95f1d3000d7b5",))# 오디오 저장with open("output.wav", "wb") as f: f.write(result.audio_bytes())print(f"Duration: {result.audio_duration}s")for word in result.words: print(f" [{word.start_time:.3f}s – {word.end_time:.3f}s] {word.text}")
granularity="word"(기본값) 또는 granularity="char"를 지정하여 정렬 단위를 설정합니다.
# 문자 단위 정렬 — 일본어/중국어에 필수result = client.text_to_speech_with_timestamps(TTSRequestWithTimestamps( text="Hello. How are you?", model="ssfm-v30", voice_id="tc_60e5426de8b95f1d3000d7b5", granularity="char",))