Python: 이전 버전이 있다면 pip install --upgrade typecast-python으로 업그레이드하세요
Javascript: 이전 버전이 있다면 npm update @neosapience/typecast-js로 업그레이드하세요
2
가져오기 및 초기화
복사
AI에게 묻기
from typecast import Typecastfrom typecast.models import TTSRequest, SmartPrompt# 클라이언트 초기화client = Typecast(api_key="YOUR_API_KEY")# 텍스트를 음성으로 변환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!" )))# 오디오 파일 저장with open('typecast.wav', 'wb') as f: f.write(response.audio_data)
API 키를 두 가지 방법으로 설정할 수 있습니다:
애플리케이션 코드에서 직접 구성
셸 환경 변수로 설정
복사
AI에게 묻기
# 현재 세션에 설정export TYPECAST_API_KEY='YOUR_API_KEY'
복사
AI에게 묻기
import requestsimport osapi_key = os.environ.get("TYPECAST_API_KEY", "YOUR_API_KEY")url = "https://api.typecast.ai/v1/text-to-speech"headers = {"X-API-KEY": api_key, "Content-Type": "application/json"}payload = { "text": "Everything is going to be okay.", "model": "ssfm-v30", "voice_id": "tc_672c5f5ce59fac2a48faeaee", "prompt": { "emotion_type": "smart", "previous_text": "I just got the best news!", "next_text": "I can't wait to celebrate!" }}response = requests.post(url, headers=headers, json=payload)if response.status_code == 200: with open('typecast.wav', 'wb') as f: f.write(response.content) print("Audio file saved as typecast.wav")else: print(f"Error: {response.status_code} - {response.text}")
요청에 사용할 수 있는 Voice ID를 찾아보려면 API 레퍼런스의 캐릭터 목록 조회를 참조하세요.
타입캐스트를 효과적으로 사용하려면 Voice ID에 액세스해야 합니다. /v2/voices 엔드포인트는 고유 식별자, 이름, 지원 모델 및 감정이 포함된 사용 가능한 캐릭터의 전체 목록을 제공합니다.모델, 성별, 연령대 및 사용 사례 등의 선택적 쿼리 파라미터를 사용하여 캐릭터를 필터링할 수 있습니다.
각 캐릭터의 특성, 샘플 오디오 클립 및 권장 사용 사례에 대한 자세한 정보는 캐릭터 페이지에서 전체 캐릭터 카탈로그를 더 자세히 살펴볼 수 있습니다.
SDK
Direct API
복사
AI에게 묻기
from typecast import Typecastfrom typecast.models import VoicesV2Filter, TTSModel# 클라이언트 초기화client = Typecast(api_key="YOUR_API_KEY")# 모든 음성 가져오기 (선택적으로 모델, 성별, 나이, 사용 사례로 필터링)voices = client.voices_v2(VoicesV2Filter(model=TTSModel.SSFM_V30))print(f"Found {len(voices)} voices:")for voice in voices: for model in voice.models: print(f"ID: {voice.voice_id}, Name: {voice.voice_name}, Model: {model.version.value}, Emotions: {', '.join(model.emotions)}")
복사
AI에게 묻기
import requestsimport osapi_key = os.environ.get("TYPECAST_API_KEY", "YOUR_API_KEY")url = "https://api.typecast.ai/v2/voices"headers = {"X-API-KEY": api_key}params = {"model": "ssfm-v30"} # 선택 사항: model, gender, age, use_casesresponse = requests.get(url, headers=headers, params=params)if response.status_code == 200: voices = response.json() print(f"Found {len(voices)} voices:") for voice in voices: for model in voice['models']: print(f"ID: {voice['voice_id']}, Name: {voice['voice_name']}, Model: {model['version']}, Emotions: {', '.join(model['emotions'])}")else: print(f"Error: {response.status_code} - {response.text}")