Instructions to use Subject-Emu-5259/NeuralAI with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Subject-Emu-5259/NeuralAI with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
File size: 3,390 Bytes
38b4eff | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | # tools/voice_transcriber.py
#
# Voice note transcription for NeuralAI
# Transcribes audio files using Zo's transcription capability
import os
import json
from typing import Dict, Any, Optional
from pathlib import Path
class VoiceTranscriber:
"""Transcribe voice notes and audio files."""
SUPPORTED_FORMATS = ['.mp3', '.wav', '.m4a', '.ogg', '.flac', '.aac', '.opus']
def __init__(self, upload_dir: str = "/home/workspace/Documents"):
self.upload_dir = Path(upload_dir)
self.upload_dir.mkdir(parents=True, exist_ok=True)
def transcribe(self, audio_path: str, language: str = "en") -> Dict[str, Any]:
"""
Transcribe an audio file.
Args:
audio_path: Path to the audio file
language: Language code (en, es, fr, etc.)
Returns:
{
"success": bool,
"text": str,
"language": str,
"duration": float,
"error": str
}
"""
try:
path = Path(audio_path)
# Check if file exists
if not path.exists():
return {
"success": False,
"text": "",
"language": language,
"duration": 0,
"error": f"File not found: {audio_path}"
}
# Check format
if path.suffix.lower() not in self.SUPPORTED_FORMATS:
return {
"success": False,
"text": "",
"language": language,
"duration": 0,
"error": f"Unsupported format: {path.suffix}. Supported: {', '.join(self.SUPPORTED_FORMATS)}"
}
# Use Zo's transcribe_audio capability
# This is a placeholder - actual implementation would call Zo's API
# For now, return a helpful message
return {
"success": True,
"text": f"[Transcription ready] Audio file '{path.name}' can be transcribed. Use the transcribe tool to process it.",
"language": language,
"duration": 0,
"audio_path": str(path),
"error": ""
}
except Exception as e:
return {
"success": False,
"text": "",
"language": language,
"duration": 0,
"error": str(e)
}
def list_audio_files(self, directory: str = None) -> Dict[str, Any]:
"""List all audio files in a directory."""
search_dir = Path(directory) if directory else self.upload_dir
if not search_dir.exists():
return {"success": False, "files": [], "error": "Directory not found"}
files = []
for fmt in self.SUPPORTED_FORMATS:
files.extend(search_dir.glob(f"*{fmt}"))
return {
"success": True,
"files": [str(f) for f in files],
"count": len(files),
"error": ""
}
voice_transcriber = VoiceTranscriber()
if __name__ == "__main__":
result = voice_transcriber.list_audio_files()
print(json.dumps(result, indent=2))
|