Skip to content

Latest commit

 

History

History
333 lines (264 loc) · 7.93 KB

File metadata and controls

333 lines (264 loc) · 7.93 KB

miner-fixes

Audio Processing Subnet Setup Guide

This guide will help you set up and test the audio processing Bittensor subnet with transcription, TTS, and summarization capabilities.

🚀 Quick Setup

1. Install Dependencies

Option A: Minimal Setup (Transcription Only)

# Install minimal dependencies for transcription testing
pip install -r requirements_minimal.txt

Option B: Full Setup (All Services)

# Install all dependencies including TTS and summarization
pip install -r requirements.txt

2. Test the Transcription Pipeline

# Test the transcription pipeline with Whisper tiny
python test_transcription_simple.py

Expected output:

🎵 Testing Audio Transcription Pipeline (Simple Version)
============================================================
Initializing transcription pipeline...
Creating test audio...
Testing transcription...
✅ Transcription successful!
📝 Transcribed text: 'You'
⏱️  Processing time: 1.15s
⏱️  Total time (including model loading): 1.15s
🔧 Model used: openai/whisper-tiny

🎉 All tests passed! The transcription pipeline is working correctly.

🔧 Detailed Setup

Prerequisites

  • Python: 3.8 or higher
  • GPU: Optional but recommended for faster processing
  • RAM: Minimum 8GB, recommended 16GB+
  • Storage: At least 5GB free space for models

Step-by-Step Installation

1. Clone the Repository

git clone <repository-url>
cd bittensor-subnet-template

2. Create Virtual Environment (Recommended)

# Using conda
conda create -n audio-subnet python=3.9
conda activate audio-subnet

# Or using venv
python -m venv audio-subnet
source audio-subnet/bin/activate  # On Windows: audio-subnet\Scripts\activate

3. Install PyTorch (GPU Support)

# For CUDA 11.8
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

# For CPU only
pip install torch torchvision torchaudio

4. Install Core Dependencies

# Core dependencies
pip install transformers>=4.30.0
pip install librosa>=0.10.0
pip install soundfile>=0.12.0
pip install numpy>=1.20.0
pip install scipy>=1.10.0

5. Install Optional Dependencies

For TTS Support
pip install TTS>=0.20.0
For Full Bittensor Integration
pip install bittensor>=5.0.0

3. Verify Installation

Test Transcription Pipeline

python test_transcription_simple.py

Test TTS Pipeline (if installed)

python -c "
from template.pipelines import TTS_AVAILABLE
if TTS_AVAILABLE:
    print('✅ TTS pipeline is available')
else:
    print('❌ TTS pipeline not available - install with: pip install TTS')
"

Test Summarization Pipeline (if installed)

python -c "
from template.pipelines import SUMMARIZATION_AVAILABLE
if SUMMARIZATION_AVAILABLE:
    print('✅ Summarization pipeline is available')
else:
    print('❌ Summarization pipeline not available - install with: pip install transformers')
"

🧪 Testing Different Components

1. Transcription Testing

The transcription pipeline uses Whisper Tiny model for fast processing:

from template.pipelines.transcription_pipeline import TranscriptionPipeline

# Initialize pipeline
pipeline = TranscriptionPipeline("openai/whisper-tiny")

# Test with audio bytes
audio_bytes = create_test_audio()  # Your audio data
transcribed_text, processing_time = pipeline.transcribe(audio_bytes, language="en")
print(f"Transcribed: {transcribed_text}")
print(f"Time: {processing_time:.2f}s")

2. TTS Testing (Optional)

from template.pipelines.tts_pipeline import TTSPipeline

# Initialize pipeline
pipeline = TTSPipeline("tts_models/en/ljspeech/tacotron2-DDC")

# Test synthesis
text = "Hello, this is a test for text to speech synthesis."
audio_bytes, processing_time = pipeline.synthesize(text, language="en")
print(f"Audio generated in {processing_time:.2f}s")

3. Summarization Testing (Optional)

from template.pipelines.summarization_pipeline import SummarizationPipeline

# Initialize pipeline
pipeline = SummarizationPipeline("facebook/bart-large-cnn")

# Test summarization
text = "Your long text here..."
summary, processing_time = pipeline.summarize(text, language="en")
print(f"Summary: {summary}")
print(f"Time: {processing_time:.2f}s")

🚀 Running the Subnet

1. Run a Miner

# Basic miner
python neurons/miner.py

# With custom configuration
python neurons/miner.py --config path/to/config.yaml

2. Run a Validator

# Basic validator
python neurons/validator.py

# With custom configuration
python neurons/validator.py --config path/to/config.yaml

🔧 Configuration

Miner Configuration

neuron:
  sample_size: 5
  min_stake: 1000
  
# Model configurations
transcription_model: "openai/whisper-tiny"
tts_model: "tts_models/en/ljspeech/tacotron2-DDC"
summarization_model: "facebook/bart-large-cnn"

Validator Configuration

neuron:
  sample_size: 5  # Top 5 miners
  max_acceptable_time: 10.0
  
# Reward weights
speed_weight: 0.4
accuracy_weight: 0.4
stake_weight: 0.2

🐛 Troubleshooting

Common Issues

1. TTS Module Not Found

ModuleNotFoundError: No module named 'TTS'

Solution: Install TTS package

pip install TTS>=0.20.0

2. CUDA Out of Memory

RuntimeError: CUDA out of memory

Solution: Use smaller models or CPU

# Use CPU instead of GPU
pipeline = TranscriptionPipeline("openai/whisper-tiny")
pipeline.device = "cpu"

3. Model Download Issues

ConnectionError: Failed to download model

Solution: Check internet connection or use offline models

# Set HuggingFace cache directory
export HF_HOME=/path/to/cache

4. Audio Processing Errors

librosa.util.exceptions.ParameterError

Solution: Ensure audio format is supported

# Convert audio to supported format
import librosa
audio, sr = librosa.load("audio.wav", sr=16000)

Performance Optimization

1. GPU Acceleration

# Install CUDA version of PyTorch
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

2. Model Caching

# Set cache directory
export HF_HOME=/path/to/cache
export TORCH_HOME=/path/to/cache

3. Memory Optimization

# Use smaller models for faster processing
pipeline = TranscriptionPipeline("openai/whisper-tiny")  # 39MB vs 1.5GB for large

📊 Performance Benchmarks

Transcription (Whisper Tiny)

  • Model Size: 39MB
  • Processing Speed: 1-3 seconds for 30-second audio
  • Memory Usage: ~2GB RAM
  • Accuracy: ~90%+ on clear speech

TTS (Tacotron2-DDC)

  • Model Size: 50MB
  • Processing Speed: 2-5 seconds for 100 words
  • Memory Usage: ~3GB RAM
  • Quality: High-quality speech synthesis

Summarization (BART Large CNN)

  • Model Size: 400MB
  • Processing Speed: 1-2 seconds for 500 words
  • Memory Usage: ~4GB RAM
  • Quality: High-quality summaries

🌍 Supported Languages

Language Code Transcription TTS Summarization
English en
Spanish es
French fr
German de
Italian it
Portuguese pt
Russian ru
Japanese ja
Korean ko
Chinese zh

📞 Support

  • Issues: Report bugs on GitHub
  • Discord: Join Bittensor Discord for community support
  • Documentation: Check AUDIO_SUBNET_README.md for detailed information