Skip to content

Commit bc213f4

Browse files
author
Pierre
committed
add: url= option for audio file.
1 parent 010e6b9 commit bc213f4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,12 @@ class AudioClassification(BaseModel):
370370
async def classify_audio(input: AudioInput) -> AudioClassification:
371371
...
372372

373+
# Example 1: Using base64 encoded data
373374
audio = 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+
375379
run = await classify_audio(AudioInput(audio=audio))
376380
run.print_output()
377381
```

examples/04_audio_classifier.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)