Use this file to discover all available pages before exploring further.
이 문서는 영어 원문을 기반으로 자동 번역되었습니다. 표현이 어색하거나 모호한 부분이 있을 수 있으니, 정확한 내용은 영어 원문을 함께 확인해 주세요.
Supertone API는 오디오와 함께 음소(phoneme) 데이터를 반환할 수 있습니다. 음소는 모델이 발화한 개별 소리 단위로, 각 음소의 시작 시간과 지속 시간이 함께 제공됩니다. 이 데이터는 게임과 애니메이션의 립싱크 구동, 가라오케 스타일의 단어 하이라이팅, 발음 분석 등에 활용할 수 있습니다.이 기능을 사용하려면 TTS 요청에 include_phonemes: true를 설정해 주십시오.
sona_speech_2, sona_speech_2_flash, sona_speech_1에서 지원됩니다. supertonic_api_3 및 supertonic_api_1에서는 지원되지 않습니다.
import base64import osfrom supertone import SupertoneVOICE_ID = "20160a4c5ba38967330c84" # replace with your voice IDwith Supertone(api_key=os.environ["SUPERTONE_API_KEY"]) as client: response = client.text_to_speech.create_speech( voice_id=VOICE_ID, text="Hello, world.", language="en", include_phonemes=True, ) result = response.result with open("speech.wav", "wb") as f: f.write(base64.b64decode(result.audio_base64)) for symbol, start, duration in zip( result.phonemes.symbols, result.phonemes.start_times_seconds, result.phonemes.durations_seconds, ): print(f"{symbol!r} at {start:.3f}s for {duration:.3f}s")
import { Supertone } from "@supertone/supertone";import * as fs from "node:fs";const VOICE_ID = "20160a4c5ba38967330c84"; // replace with your voice IDconst client = new Supertone({ apiKey: process.env.SUPERTONE_API_KEY });const response = await client.textToSpeech.createSpeech({ voiceId: VOICE_ID, apiConvertTextToSpeechUsingCharacterRequest: { text: "Hello, world.", language: "en", includePhonemes: true, },});const result = response.result as { audioBase64: string; phonemes?: { symbols?: string[]; startTimesSeconds?: number[]; durationsSeconds?: number[]; };};fs.writeFileSync("speech.wav", Buffer.from(result.audioBase64, "base64"));const symbols = result.phonemes?.symbols ?? [];const starts = result.phonemes?.startTimesSeconds ?? [];const durations = result.phonemes?.durationsSeconds ?? [];for (let i = 0; i < symbols.length; i++) { console.log(`${symbols[i]} at ${starts[i].toFixed(3)}s for ${durations[i].toFixed(3)}s`);}