Skip to main content

speechio

中文

speechio is a Python library for speech recognition, speech synthesis, and voice cloning. Use local models or connect to supported cloud services with your API key to add speech capabilities to your application.

Features

  • Speech recognition: transcribe audio files, in-memory audio, or microphone input, with live results and utterance segmentation.
  • Speech synthesis: generate complete audio or receive audio chunks from models that support streaming.
  • Voice cloning: create a voice from a reference recording, save it for reuse, or provide a reference recording when synthesizing speech.
  • Model extensions: integrate other local models or cloud services through custom adapters.
  • Example application: try recognition, synthesis, and cloning in a browser, and inspect parameters and events in the debug console.

Available capabilities depend on the selected model. Your application handles conversation replies, business workflows, and audio playback.

Install

Requires Python 3.11–3.13:

pip install speechio

The default installation includes dependencies for cloud calls, audio processing, microphone input, voice activity detection, and wake words. Cloud calls require your service credentials. Some wake-word engines also require model files or an AccessKey.

For local recognition or synthesis, install the optional dependency group for your model:

Local model Install command
Whisper pip install "speechio[stt-whisper]"
Nemotron pip install "speechio[stt-nemotron]"
Qwen3-TTS Base pip install "speechio[tts-qwen]"
Kokoro pip install "speechio[tts-kokoro]"

Installing dependencies does not download recognition or synthesis models. Load an existing complete model directory, or download the model separately first. System dependencies, Python compatibility, and GPU support depend on the selected runtime. See installation and runtime requirements (Chinese).

Quick start

For detailed usage instructions, read the basic usage guide (Chinese), which covers model configuration, API parameters, speech recognition, speech synthesis, and voice cloning.

The following examples use Alibaba Cloud Bailian.

Audio to text

Prepare a speech.wav recording no longer than 300 seconds. You can also use a supported format such as MP3 or M4A:

import os

from speechio import RemoteModelConfig, TranscriptionOptions, transcribe_audio

config = RemoteModelConfig(
    provider="bailian",
    model="qwen-audio-3.1-asr-flash",
    api_key=os.environ["DASHSCOPE_API_KEY"],
)
result = transcribe_audio(
    "speech.wav",
    config=config,
    options=TranscriptionOptions(language="en"),
)
print(result.text)

This short-audio model also checks request size. Use the file transcription model for longer recordings. See speech recognition (Chinese) for microphone, realtime, and long-file examples.

Text to audio

Select a voice supported by the model, then generate and save a WAV file:

import os

from speechio import RemoteModelConfig, SynthesisOptions, synthesize

config = RemoteModelConfig(
    provider="bailian",
    model="qwen-audio-3.1-tts-flash",
    api_key=os.environ["DASHSCOPE_API_KEY"],
)
audio = synthesize(
    "Hello. Welcome to today's practice.",
    config=config,
    options=SynthesisOptions(voice="Emily_v3.1", language="en"),
)
audio.save("hello.wav")

The output is hello.wav; saving does not overwrite an existing file by default. See speech synthesis (Chinese) for streaming output. To create a voice from your own recording, see voice cloning and reuse (Chinese).

For local models, use LocalModelConfig(adapter=..., model_path=...) to select an adapter and an existing model directory. See model configuration (Chinese) for download and configuration steps.

Supported models

Model Runs on Main capabilities
Whisper Local machine File transcription; updates live text by repeatedly transcribing accumulated audio
Nemotron 3.5 ASR 0.6B Local machine File transcription and native streaming; the current adapter supports CPU only
Qwen3-TTS 12Hz Base, 0.6B / 1.7B Local machine Complete synthesis and voice cloning; the current adapter does not provide streaming synthesis
Kokoro 82M v1.1-zh Local machine Chinese and English synthesis, with audio output by text segment; no voice cloning
qwen-audio-3.1-asr-flash Alibaba Cloud Bailian Whole-audio transcription for short recordings
qwen-audio-3.1-asr-flash-streaming Alibaba Cloud Bailian Native streaming recognition; also accepts complete audio input
qwen-audio-3.1-asr-flash-filetrans Alibaba Cloud Bailian Long-file transcription from local files or URLs accessible to the service
qwen-audio-3.1-tts-flash Alibaba Cloud Bailian Complete and streaming synthesis, incremental text input, and voice cloning

Local calls use existing model files. Cloud calls send input to the selected service. See the usage guide (Chinese) for input limits, device requirements, and voice compatibility.

Web example application

The repository includes an example application and a debug console for recording and file transcription, speech synthesis, voice cloning, and voice reuse. The console also exposes parameters and events. Both call the same core package APIs and are not installed by pip install speechio.

Install uv, clone the repository, and enter its directory:

git clone https://github.com/anwen0724/speechio.git
cd speechio

On first use, copy apps/web/config.example.toml to apps/web/config.toml. If you already have a configuration file, edit it directly:

  • For cloud models, fill in apikey in the model entry, or copy apps/web/.env.example to apps/web/.env and set your key. Credential precedence is configuration apikey, process environment, then .env; blank values are skipped.
  • For local models, enter an existing model directory and enable the corresponding entry in the configuration example.

To use cloud models, start the application with:

uv run --group web python -m apps.web --enable-debug

For local models, add the corresponding --extra. For example, to use Whisper:

uv run --group web --extra stt-whisper python -m apps.web --enable-debug

The other local groups are stt-nemotron, tts-qwen, and tts-kokoro. Repeat --extra to select multiple groups. These options install runtime dependencies; they do not download models or guarantee a working GPU environment.

Press Ctrl+C in the server terminal to stop it. Omit --enable-debug if you do not need the console. The application listens on localhost and runs one task at a time. Local configuration and credential files are covered by Git ignore rules.

License

speechio is licensed under the MIT License. Copyright © 2026 anwen.

The bundled Silero detection model includes its license; see the model asset notes. Other models, dependencies, and cloud services have their own licenses and terms.

Metadata

Release files for speechio 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for speechio 0.3.0
File Size Uploaded Provenance Actions
speechio-0.3.0.tar.gz 1.5 MB Without provenance Details for speechio-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for speechio 0.3.0
File Interpreter ABI Platform Actions
speechio-0.3.0-py3-none-any.whl Python 3 none any Details for speechio-0.3.0-py3-none-any.whl

Total release size: 2.7 MB

Release files / speechio-0.3.0.tar.gz

Download URL speechio-0.3.0.tar.gz
Size 1.5 MB
Tags Source
SHA-256 checksum
How to use checksums
0363105fa31c849b6d1944b150f65c1ca2469f0624a2d71c8ff3168a39110aba
BLAKE2b-256 checksum
How to use checksums
b11f57674ae66d0484ffa79dbbb371827c8cac5323497bf95e640832eca3ef42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / speechio-0.3.0-py3-none-any.whl

Download URL speechio-0.3.0-py3-none-any.whl
Size 1.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
4ac8333967b575bf28d3af11aeb228b1ad16ccffcf12c0a80e7fb183b52bc622
BLAKE2b-256 checksum
How to use checksums
b83720dd68034204873aa0833ac9185322d51e004f3236645ca84980df61711d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Security for speechio 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page