Standardized output for all transcription plugins.
Testing AudioData
AudioData implements the FileBackedDTO protocol, which means the RemotePluginProxy will automatically serialize it to a temp file before sending to the Worker.
# Test AudioData creationaudio = AudioData( samples=np.sin(np.linspace(0, 2*np.pi*440, 16000)), # 1 second of 440Hz tone sample_rate=16000)print(f"AudioData: {len(audio.samples)} samples at {audio.sample_rate}Hz")# Test FileBackedDTO protocolprint(f"\nImplements FileBackedDTO: {isinstance(audio, FileBackedDTO)}")# Test to_temp_file (this is what the Proxy calls)temp_path = audio.to_temp_file()print(f"Saved to temp file: {temp_path}")# Verify the file exists and can be read backimport osprint(f"File exists: {os.path.exists(temp_path)}")print(f"File size: {os.path.getsize(temp_path)} bytes")# Clean upos.unlink(temp_path)
AudioData: 16000 samples at 16000Hz
Implements FileBackedDTO: True
Saved to temp file: /tmp/tmpadmpzdp4.wav
File exists: True
File size: 32044 bytes
# Test minimal result (only text required)minimal = TranscriptionResult(text="Just the text")print(f"Minimal result: {minimal}")# Test from_file class method (if audio file available)# audio_loaded = AudioData.from_file("path/to/audio.wav")
Minimal result: TranscriptionResult(text='Just the text', confidence=None, segments=None, metadata={})