The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
from dedalus_labs import DedalusLabsclient = DedalusLabs()# Basic translation from any language to Englishwith open("french_audio.mp3", "rb") as audio_file: translation = client.audio.translations.create( file=audio_file, model="openai/whisper-1" )print(translation.text)
# Get detailed translation with timestampswith open("spanish_interview.wav", "rb") as audio_file: translation = client.audio.translations.create( file=audio_file, model="openai/whisper-1", response_format="verbose_json" )print(f"Original language: {translation.language}")print(f"Duration: {translation.duration}s")print(f"English translation: {translation.text}")for segment in translation.segments: print(f"{segment.start:.2f}s - {segment.end:.2f}s: {segment.text}")
# Generate English SRT subtitles from foreign language audiowith open("german_video.m4a", "rb") as audio_file: srt_output = client.audio.translations.create( file=audio_file, model="openai/whisper-1", response_format="srt" )with open("english_subtitles.srt", "w") as f: f.write(srt_output.text)
# Use prompt to guide translation stylewith open("japanese_presentation.wav", "rb") as audio_file: translation = client.audio.translations.create( file=audio_file, model="openai/whisper-1", prompt="This is a technical presentation about AI and machine learning.", temperature=0.2 )print(translation.text)
# Get plain text translationwith open("mandarin_lecture.mp3", "rb") as audio_file: translation = client.audio.translations.create( file=audio_file, model="openai/whisper-1", response_format="text" )with open("lecture_translation.txt", "w") as f: f.write(translation.text)