A Python package for speech recognition.
Project description
ClaraSR
A Python package for speech recognition and command processing with wake word detection.
Features
- Continuous speech recognition
- Configurable wake word detection
- Real-time audio processing
- Command extraction and processing
- Simple and intuitive API
Installation
pip install clarasr
Requirements
- Python 3.6 or higher
- PyAudio
- SpeechRecognition
- NumPy
- PyTorch
- Requests
Quick Start
from clarasr import config, startup, get, exit
# Configure the system (optional)
config(wake_word="clara", energy_threshold=1000)
# Start the speech recognition system
startup()
try:
while True:
# Get the latest recognized text
text = get()
if text:
print(f"Recognized: {text}")
time.sleep(0.1)
except KeyboardInterrupt:
# Clean up and exit
exit()
API Reference
Configuration
config(
wake_word="clara", # The word to trigger command processing
energy_threshold=1000, # Audio energy threshold for silence detection
processing_delay=1.5, # Delay between wake word detections (seconds)
min_command_length=3 # Minimum words for a valid command
)
Core Functions
startup(): Start the speech recognition systemget(): Get the latest recognized textexit(): Stop the speech recognition system
Advanced Usage
from clarasr import (
AudioSegment,
detect_silence,
contains_wake_word,
find_wake_word_position,
extract_command,
process_command
)
# Example of custom command processing
def custom_process_command(command):
if command:
print(f"Processing custom command: {command}")
return True
return False
# Configure and start the system
config(wake_word="assistant")
startup()
try:
while True:
text = get()
if text:
# Custom command processing
if contains_wake_word(text, "assistant"):
command = extract_command([AudioSegment(text, datetime.now(), b"")], "assistant")
if command:
custom_process_command(command)
time.sleep(0.1)
except KeyboardInterrupt:
exit()
License
MIT License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
clarasr-0.1.4.tar.gz
(4.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clarasr-0.1.4.tar.gz.
File metadata
- Download URL: clarasr-0.1.4.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7c097793f1bc2286863b9a45f215e6b23639a16ba375236cf479a48f236ae4c
|
|
| MD5 |
621e266afe256524385ae3987d227090
|
|
| BLAKE2b-256 |
6c9936ddeb4bf49821dda375a9dc7a07edf5dd07a8eb5b793ee7bf22bfa23eac
|
File details
Details for the file clarasr-0.1.4-py3-none-any.whl.
File metadata
- Download URL: clarasr-0.1.4-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95aff70aafa03b89309c8a1639d3d7a489ac3455687ca2ac0ec99d1fd34b7e3a
|
|
| MD5 |
7a4316994328f67c447a2a96681f30fc
|
|
| BLAKE2b-256 |
7bfff8bfcbf98f3d5e5ce050fa21229a9cfcd8512161afba639a2d64e66bae57
|