🐍 PYTHON SDK & REST API GUIDE 2026

Python Speech to Text API Quickstart

📅 Published: February 2026🔄 Updated: August 1, 2026⏱️ 7 min read

Learn how to integrate YourVoic Speech to Text API in Python. This quickstart guide provides production-ready code examples for synchronous audio file transcription using requests and real-time streaming over WebSockets using asyncio and websockets.

Key Takeaways & Summary Answer for Developers

  • Python Integration Options: Use standard HTTP requests for batch audio file transcription; use websockets + asyncio for real-time live audio streaming.
  • Key Features Included: Sub-180ms partial transcription frames, speaker diarization (Speaker 1, Speaker 2), word timestamps, and Hinglish code-switching across 93+ languages.
  • Related SDK Guides: Explore our JavaScript & Node.js Quickstart or view our Speech to Text API Overview.
  • Free Signup Allowance: Includes 2,500 free credits for API and 1,000 free credits for web interface upon signup with no credit card required.

Try Python Speech to Text Transcriber

Upload an audio file or record speech to test our Python STT API model live.

⚡ Free Trial: 3 of 3 Free Transcriptions Left⏱️ Max 2 Minutes Per Audio File (Trimmed if longer)

1. Audio Input

Click to upload or drag & drop audio

MP3, WAV, M4A, FLAC (Max 25MB • Up to 2 mins audio)

OR

2. Model & Settings

3. Transcription Result

Your transcribed text will appear here

Upload an audio file (up to 2 mins) or record live speech to transcribe speech to text.

What is Python Speech to Text API Integration?

Python Speech to Text API integration allows Python applications, data pipelines, and web servers (such as FastAPI, Django, or Flask) to programmatically submit audio recordings or live microphone streams to YourVoic’s cloud neural engine and receive JSON transcripts containing text, speaker labels, and word timestamps.

Read the official Python Requests Documentation and Python Asyncio Library Reference for HTTP and WebSocket protocols.

How Do You Transcribe Audio Files in Python Using YourVoic REST API?

To transcribe pre-recorded audio files (MP3, WAV, M4A, FLAC, OPUS up to 25MB), send an HTTP POST request to https://yourvoic.com/api/v1/transcription/sync with multipart form-data.

Python (REST File Upload Example)
# Step 1: Install requests library
# pip install requests

import requests
import json

# YourVoic API Endpoint & Key
API_URL = "https://yourvoic.com/api/v1/transcription/sync"
API_KEY = "YOURVOIC_API_KEY"  # Replace with key from yourvoic.com dashboard

def transcribe_audio(file_path):
    headers = {
        "Authorization": f"Bearer {API_KEY}"
    }
    
    # Optional metadata parameters
    data = {
        "model": "cipher_max",       # Options: "cipher_fast" or "cipher_max"
        "language": "hi",            # Language code: "hi", "en", "ta", "te", "auto"
        "response_format": "verbose_json", # Returns speaker diarization & timestamps
        "diarization": "true"
    }
    
    with open(file_path, "rb") as audio_file:
        files = {"file": audio_file}
        print("Sending audio to YourVoic Speech to Text API...")
        response = requests.post(API_URL, headers=headers, data=data, files=files)
    
    if response.status_code == 200:
        result = response.json()
        print("\n=== Transcription Result ===")
        print("Text:", result.get("text"))
        print("\n=== Speaker Diarization ===")
        for segment in result.get("segments", []):
            print(f"[{segment['start']:.2f}s - {segment['end']:.2f}s] {segment.get('speaker', 'Speaker')}: {segment['text']}")
        return result
    else:
        print(f"Error {response.status_code}: {response.text}")
        return None

if __name__ == "__main__":
    transcribe_audio("sample_recording.mp3")

How Do You Stream Real-Time Audio Over WebSockets in Python?

To transcribe live microphone audio or streaming calls with sub-180ms latency, connect to wss://yourvoic.com/api/v1/transcription/stream using websockets and stream 4KB PCM audio frames.

Python (Real-Time WebSocket Streaming)
# Step 1: Install asyncio & websockets
# pip install websockets asyncio

import asyncio
import websockets
import json

STREAM_URL = "wss://yourvoic.com/api/v1/transcription/stream"
API_KEY = "YOURVOIC_API_KEY"

async def stream_audio_from_microphone():
    headers = {
        "Authorization": f"Bearer {API_KEY}"
    }
    
    async with websockets.connect(STREAM_URL, extra_headers=headers) as websocket:
        print("Connected to YourVoic Real-Time WebSocket API!")
        
        # Task 1: Receive live partial transcripts
        async def receive_transcripts():
            async for message in websocket:
                data = json.loads(message)
                if data.get("type") == "partial":
                    print(f"⚡ Live Transcript: {data.get('text')}", end="\r")
                elif data.get("type") == "final":
                    print(f"\n✓ Final Segment: {data.get('text')}")

        # Task 2: Send PCM audio chunks (4KB frames)
        async def send_audio_chunks():
            with open("live_audio_stream.pcm", "rb") as pcm_file:
                while chunk := pcm_file.read(4096):
                    await websocket.send(chunk)
                    await asyncio.sleep(0.05)  # 50ms chunk interval
            await websocket.send(json.dumps({"type": "end_of_stream"}))

        await asyncio.gather(receive_transcripts(), send_audio_chunks())

if __name__ == "__main__":
    asyncio.run(stream_audio_from_microphone())

What Is the Pricing and Free Developer Allowance for Python SDKs?

YourVoic Speech to Text API charges $0.002 per audio minute (₹0.15/min) on Cipher Fast and $0.004 per minute on Cipher Max. All new developer accounts receive 2,500 free credits for API and 1,000 free credits for the web interface upon signup with zero credit card required.

Frequently Asked Questions (FAQs)

Start Building in Python Today

Claim your 2,500 free credits for API and 1,000 free credits for the web interface. Build voice bots, audio analytics, and dictation apps in Python.