File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -370,8 +370,12 @@ class AudioClassification(BaseModel):
370370async def classify_audio(input : AudioInput) -> AudioClassification:
371371 ...
372372
373+ # Example 1: Using base64 encoded data
373374audio = File(content_type = ' audio/mp3' , data = ' <base 64 encoded data>' )
374375
376+ # Example 2: Using a URL
377+ # audio = File(url='https://example.com/audio/call.mp3')
378+
375379run = await classify_audio(AudioInput(audio = audio))
376380run.print_output()
377381```
Original file line number Diff line number Diff line change @@ -104,15 +104,20 @@ async def main():
104104 "Please make sure you have the example audio file in the correct location." ,
105105 )
106106
107+ # Example 1: Using a local file (base64 encoded)
107108 with open (audio_path , "rb" ) as f :
108109 audio_data = f .read ()
109110
110- # Create audio input (base64 encoded)
111111 audio = File (
112112 content_type = "audio/mp3" ,
113113 data = base64 .b64encode (audio_data ).decode (),
114114 )
115115
116+ # Example 2: Using a URL instead of base64 (commented out)
117+ # audio = File(
118+ # url="https://example.com/audio/call.mp3"
119+ # )
120+
116121 # Classify the audio
117122 run = await classify_audio (AudioInput (audio = audio ))
118123
You can’t perform that action at this time.
0 commit comments