Last active
November 8, 2024 00:53
-
-
Save sanchit-gandhi/781dd7003c5b201bfe16d28634c8d4cf to your computer and use it in GitHub Desktop.
The Whisper JAX demo can be used as an endpoint through the Gradio Client library. The transcription API takes as input the audio file you want to transcribe, as well as optional arguments such as the task (transcribe or translate) and whether to return timestamps.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gradio_client import Client | |
API_URL = "https://sanchit-gandhi-whisper-jax.hf.space/" | |
# set up the Gradio client | |
client = Client(API_URL) | |
def transcribe_audio(audio_path, task="transcribe", return_timestamps=False): | |
"""Function to transcribe an audio file using the Whisper JAX endpoint.""" | |
if task not in ["transcribe", "translate"]: | |
raise ValueError("task should be one of 'transcribe' or 'translate'.") | |
text, runtime = client.predict( | |
audio_path, | |
task, | |
return_timestamps, | |
api_name="/predict_1", | |
) | |
return text | |
# transcribe an audio file using the Whisper JAX endpoint | |
output = transcribe_audio("audio.mp3") | |
# transcribe and return timestamps | |
output_with_timestamps = transcribe_audio("audio.mp3", return_timestamps=True) |
I leave a working sample here: https://colab.research.google.com/drive/11J39vhEu-JfPOoMK9P_d9lU7f_9ZHJ_w hope others find it helpful.
@abdshomad @sanchit-gandhi can you please make available whisper jax with diarization because i testes it on a 40min icelandic audio and it always return error
@sanchit-gandhi Any way to increase the timeout? The default seems to be 60 seconds.
The API_URL seems to only be forwarding gateway. And now the gateway is failing. Where was the service running on the other end?
https://sanchit-gandhi-whisper-jax.hf.space/ is just an nginx container to forward requests to the API_URL stored in the hugging face secret for the project.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can we do it with only requests instead of using gradio_client why do we need that can we do that ?