/deepinfra-python

Unofficial Python wrapper for the DeepInfra Inference API

Primary LanguagePythonMIT LicenseMIT

Bugs Code Smells Duplicated Lines (%) Build Status PyPI version Python Version License

deepinfra

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.

Installation

To install deepinfra, run the following command:

pip install deepinfra

Examples

Use Automatic Speech Recognition

You can use the Automatic Speech Recognition (ASR) API to transcribe audio files, URLs and buffer objects.

Transcribe an audio file

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"])

Transcribe an audio URL

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"])