μΈμ¦ ν ν°μΌλ‘ batch / stream νΈμΆνλ λ°©λ²
λͺ¨λ TTS νΈμΆμ /v1/external/text-to-speech/... κ²½λ‘μ
Authorization: Bearer <token> ν€λλ₯Ό λΆμ¬μ μνν©λλ€.
export CHTTS_API_KEY="<λ°κΈλ°μ ν ν°>"
μ 체 μ€λμ€λ₯Ό ν λ²μ μμ±ν΄ WAV νμΌλ‘ μ μ₯ν©λλ€.
curl -sS -X POST 'https://ch-tts-streaming-demo.channel.io/v1/external/text-to-speech/test-voice' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $CHTTS_API_KEY" \
-d '{"text":"μλ
νμΈμ, μ±λν‘μ
λλ€.","output_format":"wav_24000"}' \
--output out.wav \
-w '\nHTTP_STATUS:%{http_code}\n'
μ μ μλ΅: 200 + out.wav (RIFF/WAVE, 24kHz mono)
afplay out.wav
μ€λμ€ μ²ν¬λ₯Ό μ€μκ°μΌλ‘ μ€νΈλ¦¬λ°ν©λλ€. output_formatμ pcm_*λ§ μ§μν©λλ€
(μ€νΈλ¦Ό μλ΅μ wav_*λ₯Ό μ§μνμ§ μμ΅λλ€).
curl -sS -N -X POST 'https://ch-tts-streaming-demo.channel.io/v1/external/text-to-speech/test-voice/stream?optimize_streaming_latency=0' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $CHTTS_API_KEY" \
-d '{"text":"μλ
νμΈμ, μ±λν‘μ
λλ€.","output_format":"pcm_24000"}' \
--output out.pcm \
-w '\nHTTP_STATUS:%{http_code}\n'
μ μ μλ΅: 200 + out.pcm (raw PCM16LE, mono, 24000Hz)
python3 - <<'PY'
import wave
with open("out.pcm", "rb") as f:
data = f.read()
with wave.open("out_from_stream.wav", "wb") as w:
w.setnchannels(1)
w.setsampwidth(2)
w.setframerate(24000)
w.writeframes(data)
PY
afplay out_from_stream.wav
curl -sS -N -X POST 'https://ch-tts-streaming-demo.channel.io/v1/external/text-to-speech/test-voice/stream?optimize_streaming_latency=0' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $CHTTS_API_KEY" \
-d '{"text":"μλ
νμΈμ, μ±λν‘μ
λλ€.","output_format":"pcm_24000"}' \
| ffplay -nodisp -autoexit -f s16le -ar 24000 -ch_layout mono -i -
ν ν° κ²μ΄ν μ΄ μλλλ‘ λμνλμ§ λΉ λ₯΄κ² κ²μ¦νκ³ μΆμ λ:
| μΌμ΄μ€ | κΈ°λ κ²°κ³Ό |
|---|---|
| external μλν¬μΈνΈ, ν ν° μμ | 401 |
| external μλν¬μΈνΈ, μ¬λ°λ₯Έ ν ν° (batch) | 200 |
| external μλν¬μΈνΈ, μ¬λ°λ₯Έ ν ν° (stream) | 200 |
# external μλν¬μΈνΈ, ν ν° μμ΄ -> 401
curl -sS -o /dev/null -X POST 'https://ch-tts-streaming-demo.channel.io/v1/external/text-to-speech/test-voice' \
-H 'Content-Type: application/json' \
-d '{"text":"test","output_format":"wav_24000"}' \
-w 'HTTP_STATUS:%{http_code}\n'
# external μλν¬μΈνΈ, μ¬λ°λ₯Έ ν ν° -> 200
curl -sS -o /dev/null -X POST 'https://ch-tts-streaming-demo.channel.io/v1/external/text-to-speech/test-voice' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $CHTTS_API_KEY" \
-d '{"text":"test","output_format":"wav_24000"}' \
-w 'HTTP_STATUS:%{http_code}\n'
Β· voice_idλ νμ¬ λ¬΄μλλ©° κ°μ 무κ΄ν©λλ€ (μμμμλ test-voice μ¬μ©).
Β· /health, /pingμ μΈμ¦ μμ΄ νμ νΈμΆ κ°λ₯ν©λλ€.
Β· μΈν°λν°λΈ API λ¬Έμ(νλΌλ―Έν°/μ€ν€λ§/Try it out)λ Swagger UI λλ ReDocμμ νμΈνμΈμ.