deepinfra
is a Python library designed to provide a simple interface for interacting with DeepInfra's Inference API, facilitating various AI and machine learning tasks.
To install deepinfra
, run the following command:
pip install deepinfra
You can use the Automatic Speech Recognition (ASR) API to transcribe audio files, URLs and buffer objects.
from deepinfra import AutomaticSpeechRecognition
model_name = "openai/whisper-base"
asr = AutomaticSpeechRecognition(model_name)
file_path = "path/to/audio/file"
body = {
"audio": file_path
}
transcription = asr.generate(body)
print(transcription["text"])
from deepinfra import AutomaticSpeechRecognition
model_name = "openai/whisper-base"
asr = AutomaticSpeechRecognition(model_name)
url = "https://path/to/audio/file"
body = {
"audio": url
}
transcription = asr.generate(body)
print(transcription["text"])