Use this file to discover all available pages before exploring further.
이 문서는 영어 원문을 기반으로 자동 번역되었습니다. 표현이 어색하거나 모호한 부분이 있을 수 있으니, 정확한 내용은 영어 원문을 함께 확인해 주세요.
이 예제는 여러 문단으로 이루어진 스크립트를 받아 하나의 오디오 파일로 만들어 줍니다. SDK의 자동 청크 분할을 보여줍니다. 전체 스크립트를 create_speech에 그대로 전달하면, SDK가 문장 경계에서 분할하여 각 세그먼트를 생성하고, 결과를 하나로 병합합니다.
import osfrom supertone import SupertoneVOICE_ID = "20160a4c5ba38967330c84" # replace with your voice IDSCRIPT = """Chapter one. The clocktower struck midnight, and the wind through the oldsquare carried whispers from the workshops below. Hana adjusted her coat,checked the address one more time, and stepped through the iron gate.Inside, the air smelled of copper and lemon polish. Rows of half-finishedautomatons stared back from the shelves, each one waiting for a name. Sheset her satchel on the bench and opened her notebook to a fresh page.By dawn, the room had changed. One of the figures by the window was nolonger half-finished, and Hana, very quietly, was no longer alone.""".strip()with Supertone(api_key=os.environ["SUPERTONE_API_KEY"]) as client: response = client.text_to_speech.create_speech( voice_id=VOICE_ID, text=SCRIPT, language="en", model="sona_speech_2", voice_settings={"pitch_variance": 0.9, "speed": 0.95}, ) with open("narration.wav", "wb") as f: f.write(response.result.read())print("Saved narration.wav")
import { Supertone } from "@supertone/supertone";import * as fs from "node:fs";const VOICE_ID = "20160a4c5ba38967330c84"; // replace with your voice IDconst SCRIPT = `Chapter one. The clocktower struck midnight, and the wind through the oldsquare carried whispers from the workshops below. Hana adjusted her coat,checked the address one more time, and stepped through the iron gate.Inside, the air smelled of copper and lemon polish. Rows of half-finishedautomatons stared back from the shelves, each one waiting for a name. Sheset her satchel on the bench and opened her notebook to a fresh page.By dawn, the room had changed. One of the figures by the window was nolonger half-finished, and Hana, very quietly, was no longer alone.`.trim();const client = new Supertone({ apiKey: process.env.SUPERTONE_API_KEY });const response = await client.textToSpeech.createSpeech({ voiceId: VOICE_ID, apiConvertTextToSpeechUsingCharacterRequest: { text: SCRIPT, language: "en", model: "sona_speech_2", voiceSettings: { pitchVariance: 0.9, speed: 0.95 }, },});if (response.result instanceof Uint8Array) { fs.writeFileSync("narration.wav", response.result);} else if (response.result && "getReader" in response.result) { const reader = (response.result as ReadableStream<Uint8Array>).getReader(); const chunks: Uint8Array[] = []; while (true) { const { done, value } = await reader.read(); if (done) break; if (value) chunks.push(value); } fs.writeFileSync("narration.wav", Buffer.concat(chunks));}console.log("Saved narration.wav");