Skip to main content

Noah's Local Speech Recognition

This project provides a local, privacy-preserving speech recognition tool using the Vosk speech recognition toolkit and microphone input. It supports keyword detection, timestamped transcription, logging, pause/resume functionality, and model auto-downloading.


Features

  • Offline speech recognition (no internet needed)
  • Auto-download of Vosk models if not present
  • Realtime transcription with timestamps
  • Automatic transcript logging to disk
  • Support for pause/resume listening

Requirements

  • Python 3.9+
  • vosk
  • pyaudio
  • tqdm
  • requests

Setup:

pip install noahs_local_speech_recognition

On Linux (including Raspberry Pi), pyaudio still depends on system-level PortAudio. Make sure to install portaudio19-dev and pyaudio is working before pip installing noahs_local_speech_recognition which relies on pyaudio to avoid errors.


Linux Setup Instructions

If you're using Linux, the script attempts to install the required PortAudio libraries automatically. However, you may still need to:

  1. Run the script that imports noahs_local_speech_recognition with sudo:

  2. Manually install dependencies if issues arise:

    sudo apt-get update
    sudo apt-get install -y portaudio19-dev python3-pyaudio
    pip uninstall pyaudio
    pip install pyaudio
    

These steps ensure that pyaudio is compiled correctly against the system's PortAudio library.


Demo

To test the speech recognizer locally, simply run this script:

from noahs_local_speech_recognition import get_text_after_keyword, list_microphones, start_speech_listening, stop_speech_listening, get_speech_log, get_speech_log_entry, set_speech_log_response, remove_speech_log_entry, pause_speech_listening, resume_speech_listening

import time

print("Listing available microphone devices:")
list_microphones()

print("\nStarting speech recognition with default input device...")
start_speech_listening(name="robot", stop_talking_delay=2, device_index=None, model_name="vosk-model-small-en-us-0.15")

try:
    while True:
        time.sleep(2)
        print("_________________________")
        entry = get_speech_log_entry()
        if entry and entry["response"] is None:
            heard = entry["content"]
            print(f"I HEARD: {heard}")
            speech_log1 = get_speech_log()
            print(f"SPEECH LOG BEFORE SET RESPONSE: {speech_log1}")
            set_speech_log_response("I have heard what you said")
            speech_log2 = get_speech_log()
            print(f"SPEECH LOG AFTER SET RESPONSE: {speech_log2}")
        if entry and entry["content"] in ["goodbye", "good bye", "bye", "quit", "end", "exit"]:
            break
except KeyboardInterrupt:
    pass
finally:
    stop_speech_listening()

This will:

  • Auto-download the Vosk "vosk-model-small-en-us-0.15" model if missing.
  • Show available audio devices.
  • Look for defualt microphone since device_index=None.
  • Begin listening and transcribing speech in real-time based on hearing name="robot" keyword
  • Log results with timestamps to a file named like transcript_YYYY-MM-DD_HH-MM-SS.txt.
  • Display speech_log before and after having response set in the console.
  • Use set_speech_log_response() to flag entries as having been responded to.

Changing Models

You can modify the model by altering the model_name passed to start_speech_listening():

start_speech_listening(name="robot", stop_talking_delay=2, device_index=None, model_name="vosk-model-small-en-us-0.15")

Other available models:

  • vosk-model-small-en-us-0.15
  • vosk-model-en-us-0.22
  • vosk-model-en-us-0.22-lgraph

Keyword Mode vs Always Listen Mode

To use Always Listen Mode just use name=None in start_speech_listening():

start_speech_listening(name=None, stop_talking_delay=2, device_index=None, model_name="vosk-model-small-en-us-0.15")

This will transcribe everything, not just things said after the name keyword.


Known Issues

  • Use on debian Linux may require manually setting up pyaudio prior to import
  • Automaitic Model download links are hardcoded and limited to 3 options.

License

MIT License


Acknowledgements

  • Vosk Speech Recognition Toolkit
  • TQDM for progress bars

Release files for noahs-local-speech-recognition 0.1.4

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

Source distribution (sdist)

Source distribution for noahs-local-speech-recognition 0.1.4
File Size Uploaded
noahs_local_speech_recognition-0.1.4.tar.gz 6.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for noahs-local-speech-recognition 0.1.4
File Interpreter ABI Platform
noahs_local_speech_recognition-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 13.8 kB

Release files / noahs_local_speech_recognition-0.1.4.tar.gz

Download URL noahs_local_speech_recognition-0.1.4.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
feca19c0ec840a60b64e948decdf7f0b7d95e76b162269137fcf2f1d2df8c691
BLAKE2b-256 checksum
How to use checksums
f2057de711c55106d72e8e88c9ea8f2e0bf293777db8912825834f61085f213d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.4

Release files / noahs_local_speech_recognition-0.1.4-py3-none-any.whl

Download URL noahs_local_speech_recognition-0.1.4-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc2eb099e748917f6ce57181bb0c25d036d15ac160b9f2d19b2d2b2027869ade
BLAKE2b-256 checksum
How to use checksums
8816f489e90e84511cb06d066642a3f8254fd95d4423f770ce43156823ca7951
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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