Skip to main content

Advanced voice transcription tool with multi-language support

Project description

Dhvagna-NPI: Voice Transcription Tool

Version Python License PyPI Downloads

Dhvagna-NPI Banner

Official Python package for advanced voice transcription with multi-language support. Dhvagna-NPI offers an end-to-end voice transcription suite for developers building speech recognition applications. You can easily transcribe spoken audio to text in multiple languages with a beautiful command-line interface.

With this package, you can easily perform voice transcription from any Python 3.7+ application by utilizing the provided command-line interface or importing the modules directly. Currently, Dhvagna-NPI supports both quick single transcriptions and interactive sessions with customizable settings.

To learn how to use our package, check out our documentation.


Table of Contents


Installation

To install the latest version available:

pip install dhvagna-npi

When using this package in your application, make sure to pin to at least the major version (e.g., ==0.1.*). This helps ensure your application remains stable and avoids potential issues from breaking changes in future updates.


Get Started

Dhvagna-NPI provides a simple way to transcribe voice to text:

from dhvagna_npi.core import transcribe_audio
import speech_recognition as sr

# Initialize recognizer and microphone
recognizer = sr.Recognizer()
microphone = sr.Microphone()

# Record and transcribe
with microphone as source:
    print("Listening... Speak now!")
    recognizer.adjust_for_ambient_noise(source)
    audio = recognizer.listen(source)
    success, text, _ = transcribe_audio(audio, recognizer, "en-US")
    if success:
        print(f"Transcription: {text}")

Features

  • Multi-language Support: Transcribe speech in English, Spanish, French, German, Chinese, Hindi, Telugu, and more.
  • Offline Processing: All processing happens locally - your voice data never leaves your computer.
  • Rich Command-line Interface: Beautiful terminal UI with the Rich library.
  • Customizable Settings: Adjust language, microphone sensitivity, timeout, and more.
  • Transcription History: Save and retrieve past transcriptions.
  • Multiple Export Formats: Save transcriptions as text, JSON, or CSV.

Creating Your First Transcription

from dhvagna_npi.config import Config
from dhvagna_npi.core import run_single_transcription

def main():
    # Run a single transcription and exit
    run_single_transcription()

if __name__ == "__main__":
    main()

Using the Command-Line Interface

Dhvagna-NPI provides two CLI modes:

# Quick mode (single transcription)
dhvagna-npi

# Interactive mode (multiple transcriptions with settings)
dhvagna-npi-interactive

Keyboard Controls

  • k (or custom hotkey): Start/Stop recording
  • h: Show help
  • s: Settings menu
  • v: View recent transcriptions
  • q: Quit

Customizing Settings

from dhvagna_npi.config import Config

# Create and customize configuration
config = Config()
config.language = "es-ES"  # Set language to Spanish
config.timeout = 15  # Set recording timeout to 15 seconds
config.energy_threshold = 250  # Set microphone sensitivity
config.save_transcriptions = True  # Enable saving transcriptions
config.transcription_folder = "my_transcriptions"  # Set custom folder

# Save configuration
config.save()

Supported Languages

  • English (US) - en-US
  • English (UK) - en-GB
  • Spanish - es-ES
  • French - fr-FR
  • German - de-DE
  • Chinese (Mandarin) - zh-CN
  • Hindi - hi-IN
  • Telugu - te-IN

Examples

Minimal Example

import speech_recognition as sr
from dhvagna_npi.core import transcribe_audio

# Initialize recognizer and microphone
recognizer = sr.Recognizer()
microphone = sr.Microphone()

# Record and transcribe
with microphone as source:
    print("Listening... Speak now!")
    recognizer.adjust_for_ambient_noise(source)
    audio = recognizer.listen(source)
    success, text, _ = transcribe_audio(audio, recognizer, "en-US")
    if success:
        print(f"Transcription: {text}")

Quick Transcribe Example

from dhvagna_npi.core import run_single_transcription

# Run a single transcription with default settings
run_single_transcription()

Custom Settings Example

import os
from dhvagna_npi.config import Config
from dhvagna_npi.core import transcribe_audio
import speech_recognition as sr

# Create custom configuration
config = Config()
config.language = "fr-FR"  # French
config.energy_threshold = 250  # More sensitive
config.timeout = 8  # 8 second timeout

# Initialize recognizer with custom settings
recognizer = sr.Recognizer()
recognizer.energy_threshold = config.energy_threshold
microphone = sr.Microphone()

# Record and transcribe
with microphone as source:
    print("Adjusting for ambient noise...")
    recognizer.adjust_for_ambient_noise(source)
    
    print("Listening... Speak now!")
    audio = recognizer.listen(source, timeout=config.timeout)
    
    success, text, _ = transcribe_audio(audio, recognizer, config.language)
    if success:
        print(f"French transcription: {text}")

Save to File Example

import json
import os
import datetime
from dhvagna_npi.core import transcribe_audio
import speech_recognition as sr

def save_as_text(text, language, output_dir="output"):
    """Save transcription as a text file."""
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)
        
    timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
    filename = f"transcription_{timestamp}.txt"
    filepath = os.path.join(output_dir, filename)
    
    with open(filepath, 'w', encoding='utf-8') as f:
        f.write(f"Timestamp: {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n")
        f.write(f"Language: {language}\n\n")
        f.write(text)
        
    return filepath

# Initialize recognizer and microphone
recognizer = sr.Recognizer()
microphone = sr.Microphone()

# Record and transcribe
with microphone as source:
    print("Listening...")
    recognizer.adjust_for_ambient_noise(source)
    audio = recognizer.listen(source)
    
    success, text, _ = transcribe_audio(audio, recognizer, "en-US")
    if success:
        # Save the transcription
        filepath = save_as_text(text, "en-US")
        print(f"Saved transcription to: {filepath}")

Multilingual Example

from dhvagna_npi.config import Config
from dhvagna_npi.utils import get_language_codes
from dhvagna_npi.core import transcribe_audio
import speech_recognition as sr

# Get available language codes
language_codes = get_language_codes()
print("Available languages:")
for key, language in language_codes.items():
    print(f"{key}: {language}")

# Choose a language code
language = "es-ES"  # Spanish

# Initialize recognizer and microphone
recognizer = sr.Recognizer()
microphone = sr.Microphone()

# Record and transcribe
with microphone as source:
    print(f"Recording in {language}...")
    recognizer.adjust_for_ambient_noise(source)
    audio = recognizer.listen(source)
    
    success, text, _ = transcribe_audio(audio, recognizer, language)
    if success:
        print(f"Transcription in {language}: {text}")

Available Methods

from dhvagna_npi.config import Config
from dhvagna_npi.history import TranscriptionHistory
from dhvagna_npi.utils import get_language_name

# Create a configuration
config = Config()

# Get language name from code
language_name = get_language_name("fr-FR")  # Returns "French"

# Create a history manager
history = TranscriptionHistory(config)

# Add a transcription to history
history.add("This is a test transcription")

# Get recent transcriptions
recent = history.get_recent(5)  # Get last 5 transcriptions

Documentation

For more detailed information about Dhvagna-NPI, check out the following resources:


License

This project is licensed under the MIT License - see the LICENSE file for details.

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

dhvagna_npi-0.1.3.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

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

dhvagna_npi-0.1.3-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file dhvagna_npi-0.1.3.tar.gz.

File metadata

  • Download URL: dhvagna_npi-0.1.3.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.5

File hashes

Hashes for dhvagna_npi-0.1.3.tar.gz
Algorithm Hash digest
SHA256 8fcc23e287ae6e71578b663a4d3f31a3ae8c2fe5faec0da9eb3ddf8a54ec8768
MD5 38bf904c7e5e76c924a86f90686a0a11
BLAKE2b-256 924d4a86d6f4cf8c9fbfd7daf421be99d47a91c6e80ad3cc06b22cb17cffe38c

See more details on using hashes here.

File details

Details for the file dhvagna_npi-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: dhvagna_npi-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.5

File hashes

Hashes for dhvagna_npi-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4eb05857c607f3b77d777b8395633870a536d67765ba8eeecf858243463398f3
MD5 4c41c60678fb459eddc1e1842f71943f
BLAKE2b-256 15c0e8fc335b12ab28c7ad7892bd3359f581c535f72b54bc0adf3300e48f21ca

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