File size: 1,345 Bytes
b5df735 |
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 |
"""
Audio processing interface definitions
"""
from abc import ABC, abstractmethod
from typing import Dict, Any, List, Tuple, Iterator, Optional
from dataclasses import dataclass
@dataclass
class AudioSegment:
"""Audio segment representation"""
start: float
end: float
file_path: str
duration: float
class IAudioProcessor(ABC):
"""Interface for audio processing operations"""
@abstractmethod
async def split_audio_by_silence(
self,
audio_path: str,
min_segment_length: float = 30.0,
min_silence_length: float = 1.0
) -> List[AudioSegment]:
"""Split audio file by silence detection"""
pass
@abstractmethod
async def process_audio_segment(
self,
segment: AudioSegment,
model_name: str = "turbo",
language: Optional[str] = None,
enable_speaker_diarization: bool = False
) -> Dict[str, Any]:
"""Process a single audio segment"""
pass
@abstractmethod
async def process_complete_audio(
self,
audio_path: str,
model_name: str = "turbo",
language: Optional[str] = None,
enable_speaker_diarization: bool = False,
min_segment_length: float = 30.0
) -> Dict[str, Any]:
"""Process complete audio file"""
pass |