1. Overview and quickstarts
MyVocal AI语音大模型API文档
English
  • 中文
  • English
  • 文字转语音大模型
    • API reference
      • Voice management
        • List voices
        • Create a voice
        • Delete a voice
      • HTTP synthesis
        • Streaming HTTP synthesis
        • Non-streaming HTTP synthesis
      • WebSocket synthesis
        • Standard TTS · Single connection
        • Standard TTS · Multiple contexts
        • Dialogue · Multiple contexts
      • Usage and request history
        • Get master key usage
        • Look up a request by ID
        • Get usage by voice
      • Sub-key management
        • Create a sub-key
        • List sub-keys
        • Get sub-key details
        • Update a sub-key
        • Get sub-key usage
    • Overview and quickstart
      • Models
      • Choose a model and endpoint
      • Supported languages
      • Audio formats and playback
      • FAQ
      • SDKs and examples
  • 金融行业定制TTS模型
    • Skyblight text to speech
      • Streaming text to speech
      • Non-streaming text to speech
      • List voices
      • Delete a voice
      • Create a voice
      • Get usage
    • Full-duplex communication
      • WebSocket integration guide
      • V2 bidirectional streaming synthesis (WebSocket)
  • 语音转文字ASR
    • Overview and quickstarts
      • Realtime transcription quickstart
      • File transcription quickstart
      • Models and capabilities
      • Changelog
    • API reference
      • Realtime transcription over WebSocket
      • Create a file transcription
      • Get ASR usage
  • 企业客户声音定制服务
    • Your custom brand voice
  1. Overview and quickstarts

Realtime transcription quickstart

Use a Java, Python or Go SDK with echo_v2_realtime, or connect directly over WebSocket. Keep your enterprise ASR key on your server. The release examples read raw 16 kHz mono signed 16-bit little-endian PCM. The direct WebSocket example below reads the same audio from a WAV file and removes the WAV header.

Use an SDK#

Release candidate v0.1.0-rc.1. Set MYVOCAL_API_KEY in the server process environment. The three examples below transcribe the same English recording. Use the release and checksums to verify your download.
LanguageInstall and run
Java 11+Download the Java distribution, open its java directory, and follow the JAR installation and ShortRecording example.
Python 3.11+Install the wheel. Download the tagged source, open its python directory, then run python examples/short_recording.py ../samples/english.pcm. Python examples
Go 1.21+In a Go module, run go get github.com/MyVocal-AI/enterprise-echo-v2-realtime-sdks/go@v0.1.0-rc.1. Run go run github.com/MyVocal-AI/enterprise-echo-v2-realtime-sdks/go/examples/segment -pcm english.pcm with the path to your recording. Go examples

Connect directly#

The WebSocket endpoint supports echo_v1_realtime and echo_v2_realtime. For the example below, use Python 3.10+ and install websockets>=14,<16. Save the script as realtime_asr.py. To convert the supplied raw recording to the WAV file expected by this script, run:
ffmpeg -f s16le -ar 16000 -ac 1 -i english.pcm sample.wav
python realtime_asr.py sample.wav
Wait for session_started before sending audio. With manual submission, set commit=true on the last chunk and wait for the final transcript before closing the connection.
WebSocket parameters, messages and events

Use a realtime V2 SDK (Java, Python or Go)#

Release candidate v0.1.0-rc.1. All three server SDKs support single recordings and continuous calls. Store your enterprise ASR key in the server environment variable MYVOCAL_API_KEY. The examples use raw 16 kHz mono signed 16-bit little-endian PCM.

Java 11+#

Download the Java ZIP. Follow java/README.md to install the JAR and POM. Run ShortRecording for final text and word timings, or LiveCall for a bilingual call and speaker labels.

Python 3.11+#

Python wheel · Source for this release
From the release’s python directory, run the single-recording or bilingual call example.

Go 1.21+#

Install the module in your Go project.
Replace the path with your PCM file and run the single-recording example.
Go continuous call example · Sample audio · GitHub release and SHA-256 checksums
Existing echo_v1_realtime integrations can continue using the earlier Python SDK or earlier Go SDK.

Connect directly over WebSocket (realtime V1 and V2)#

Before you start#

Python 3.10 or later.
A valid enterprise ASR API key.
A 16 kHz mono 16-bit PCM WAV file named sample.wav.
Install the dependency:
To convert an audio file, use FFmpeg:

Follow one session#

Connect → session_started → stream audio chunks
                                 ↓
                 partial_transcript → committed_transcript
Partial transcripts can change and are suitable for live display. Save the final transcript. This example uses manual submission: set commit=true on the last chunk, wait for the final result and then close the connection.

Run the example#

Save this code as realtime_asr.py. It removes the WAV header, sends raw PCM samples and receives updates while sending audio.
See the runnable Python example under Connect directly.
Set the environment variable and run the script. The commands below use Bash. In PowerShell, use $env:MYVOCAL_API_KEY="YOUR_API_KEY".
The terminal prints stage: partial followed by stage: final.

Automatic segmentation, bilingual speech and vocabulary#

See realtime V2 connection parameters and the first audio message

Additional options#

Choose a commit mode · First-frame context and vocabulary · Word timings and speakers

FAQ#

SymptomWhat to check
Connection rejectedCheck api-key and confirm that model_id is echo_v1_realtime or echo_v2_realtime.
No final transcriptIn manual mode, send commit=true and continue receiving events.
Audio is not recognizedCheck sample rate, channels and bit depth. Send only PCM samples, excluding the WAV header.
上一页
Overview and quickstarts
下一页
File transcription quickstart
Built with