Speech-to-Text
Note
Before proceeding, you should be familiar with the OpenAI Speech-to-Text and the relevant OpenAI API reference
Curl
curl http://localhost:8000/v1/audio/transcriptions -F "file=@audio.wav"
Python
import httpx
with open('audio.wav', 'rb') as f:
files = {'file': ('audio.wav', f)}
response = httpx.post('http://localhost:8000/v1/audio/transcriptions', files=files)
print(response.text)
OpenAI SDKs
Note
Although this project doesn't require an API key, all OpenAI SDKs require an API key. Therefore, you will need to set it to a non-empty value. Additionally, you will need to overwrite the base URL to point to your server.
This can be done by setting the OPENAI_API_KEY
and OPENAI_BASE_URL
environment variables or by passing them as arguments to the SDK.
import httpx
with open('audio.wav', 'rb') as f:
files = {'file': ('audio.wav', f)}
response = httpx.post('http://localhost:8000/v1/audio/transcriptions', files=files)
print(response.text)
export OPENAI_BASE_URL=http://localhost:8000/v1/
export OPENAI_API_KEY="cant-be-empty"
openai api audio.transcriptions.create -m Systran/faster-whisper-small -f audio.wav --response-format text
See OpenAI libraries.