livetranscriber
A single-file helper with minimal external dependencies that streams microphone audio to Deepgram for real-time speech-to-text. This is available as a package on PyPI.
Features
- Simple API - single
LiveTranscriberclass. - Configurable - every Deepgram LiveOptions parameter can be overridden via keyword arguments; sensible Nova-3 defaults are provided.
- Mandatory callback - forces the calling code to supply a function that will be invoked for every final transcript chunk (empty / interim chunks are ignored).
- Output capture - optional
output_pathwrites each final transcript line to disk. - Pause / resume - you may call
pauseorresumefrom your callback. - Graceful shutdown - Ctrl-C or
stopshuts everything down and releases resources.
Installation
Install the package directly from PyPI using pip:
pip install livetranscriber
Alternatively, if you are working with the source code or a specific requirements file, you can install the dependencies listed in requirements.txt:
deepgram-sdk>=4,<5
numpy>=1.24 # build-time requirement of sounddevice
sounddevice>=0.4
Install with uv (preferred) or plain pip:
uv venv .venv && source .venv/bin/activate
uv pip install -r requirements.txt
or
pip install -r requirements.txt
-
Python Version:
Python 3.11 is required.
Environment Setup
Export your Deepgram API key (see https://console.deepgram.com). For persistent access, add the following line to your shell profile file (e.g., ~/.zshrc, ~/.bashrc, or ~/.profile) and restart your terminal or source the file:
export DEEPGRAM_API_KEY="dg_…"
Example Usage
Here are examples demonstrating how to use the livetranscriber package.
Minimal Example
A basic example showing the essential setup:
from livetranscriber import LiveTranscriber
def simple_callback(text: str):
print("NEW >", text)
tr = LiveTranscriber(callback=simple_callback)
tr.run()
Comprehensive Example
A more detailed example demonstrating various features like output to file and pause/resume:
import time
from livetranscriber import LiveTranscriber
def comprehensive_callback(text: str):
print("Transcript received:", text)
# Example: Pause transcription if a specific phrase is detected
if "pause recording" in text.lower():
print("Status: PAUSING...")
transcriber.pause()
print("Status: RECORDING PAUSED. Say 'resume recording' to continue.")
# Example: Resume transcription if another phrase is detected
if "resume recording" in text.lower():
print("Status: RESUMING...")
transcriber.resume()
print("Status: RECORDING RESUMED.")
# Example: Stop transcription if a stop phrase is detected
if "stop recording" in text.lower():
print("Status: STOPPING...")
transcriber.stop()
# Instantiate with various options
output_file = "transcript_output.txt"
transcriber = LiveTranscriber(
callback=comprehensive_callback,
output_path=output_file, # Output transcript to a file
model="nova-3-general", # Specify a model
language="en-US", # Specify a language
punctuate=True, # Enable punctuation
smart_format=True # Enable smart formatting (like numbers)
)
try:
print(f"Starting transcription. Transcript will also be saved to {output_file}")
print("Instructions: Press Ctrl+C to stop, or say 'pause recording', 'resume recording', or 'stop recording'.")
transcriber.run() # Blocks until stop() is called or Ctrl-C is pressed
except KeyboardInterrupt:
print("\nInterrupted by user. Stopping.")
finally:
print("Transcription session ended.")
API
LiveTranscriber Class
High-level wrapper around Deepgram live transcription.
Parameters:
callback: A function that will be invoked for every final transcript. Must accept a singlestrargument. May be sync or async.output_path(Optional): Path to a text file that will receive each final transcript line (UTF-8).api_key(Optional): Your Deepgram API key. If omitted, theDEEPGRAM_API_KEYenvironment variable is used; failing both raisesRuntimeError.keepalive(Optional): IfTrue(default) the WebSocket client sends keepalive pings.**live_options_overrides(Optional): Any keyword argument that matches a LiveOptions field overrides the built-in defaults. For example,punctuate=False.
Methods:
run(): Run until.stop()or Ctrl-C.stop(): Public request to shut down; may be called from any thread.pause(): Pause writing transcripts tooutput_path. Note that the callback function will continue to receive transcription data while paused.resume(): Resume writing transcripts tooutput_path.
Development Standards
This section outlines the standards and practices for contributing to livetranscriber.
This project is distributed under the MIT License.
Tagging
After pushing a new version commit, always create a Git tag for that version and push the tag. For version x.y.z, the tag name should be vx.y.z.
Dependencies
deepgram-sdknumpysounddevice
Metadata
Release files for livetranscriber 0.3.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| livetranscriber-0.3.13.tar.gz | 8.6 kB | Without provenance | Details for livetranscriber-0.3.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| livetranscriber-0.3.13-py3-none-any.whl | Python 3 | none | any | Details for livetranscriber-0.3.13-py3-none-any.whl |
Total release size: 18.1 kB
Release files / livetranscriber-0.3.13.tar.gz
| Download URL | livetranscriber-0.3.13.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
023af5369a1aaf256a8aacbea997c7c3838c3efb72b49383c784b56bdab223cb
|
|
BLAKE2b-256 checksum How to use checksums |
b8cd2cabc4d1c8ee3b0cad5e01e3ff61d5a02dbbcd91ec75a3ee34c633c585cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.6
|
Release files / livetranscriber-0.3.13-py3-none-any.whl
| Download URL | livetranscriber-0.3.13-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3643653ff10255f309100f45d7b18eb7f68777f2608432eeb4002260dbcebea7
|
|
BLAKE2b-256 checksum How to use checksums |
0d1ce88a282771a82685e040c16acc753099b7810cdc1c94f45ac061ccb91bce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.6
|
Security for livetranscriber 0.3.13
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.