Skip to main content

Fast, accurate, on-device AI library for building interactive voice applications

Project description

Moonshine Voice Python Package

Python bindings for the Moonshine Voice library - a fast, accurate, on-device AI library for building interactive voice applications.

Installation

pip install moonshine-voice

Requirements

  • Python 3.8 or higher
  • The Moonshine C library (libmoonshine.so on Linux, libmoonshine.dylib on macOS, moonshine.dll on Windows)

Quick Start

from moonshine_voice import Transcriber, ModelArch

# Initialize transcriber with model files
transcriber = Transcriber(
    model_path="/path/to/models",
    model_arch=ModelArch.BASE
)

# Transcribe audio data
audio_data = [...]  # List of float samples (-1.0 to 1.0) at 16kHz
transcript = transcriber.transcribe(audio_data, sample_rate=16000)

# Print results
for line in transcript.lines:
    print(f"[{line.start_time:.2f}s] {line.text}")

# Clean up
transcriber.close()

Streaming Transcription

For real-time transcription from a microphone or live audio source:

from moonshine_voice import Transcriber, ModelArch

transcriber = Transcriber(
    model_path="/path/to/models",
    model_arch=ModelArch.BASE_STREAMING
)

# Create a stream
stream = transcriber.create_stream()
stream.start()

# Add audio chunks as they arrive
while True:
    audio_chunk = get_audio_chunk()  # Your audio capture function
    stream.add_audio(audio_chunk, sample_rate=16000)

    # Get updated transcript
    transcript = stream.transcribe()
    for line in transcript.lines:
        if line.is_updated:
            print(f"Updated: {line.text}")

stream.stop()
stream.close()
transcriber.close()

Model Architectures

  • ModelArch.TINY: Smallest model, fastest inference
  • ModelArch.BASE: Balanced model with better accuracy
  • ModelArch.TINY_STREAMING: Tiny model optimized for streaming
  • ModelArch.BASE_STREAMING: Base model optimized for streaming

Error Handling

from moonshine_voice import (
    Transcriber,
    MoonshineError,
    MoonshineInvalidHandleError,
)

try:
    transcriber = Transcriber("/path/to/models")
except MoonshineError as e:
    print(f"Error: {e}")

License

MIT License - see the main project repository for details.

Documentation

For more information, see the main Moonshine Voice documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moonshine_voice-0.0.3-py3-none-macosx_11_0_arm64.whl (65.9 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file moonshine_voice-0.0.3-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for moonshine_voice-0.0.3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1a4c5b5a3fac22298def267bb4767b70376a812ab96b7cfa597d347e4c1c05c0
MD5 05db43e5e4827751aa107dbd5080ccdc
BLAKE2b-256 91063c8acb790a8a613df8458976e204051ae6b9a2a6384dd8fb9cb0695f0689

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page