Automatic Speech Recognition

faster-whisper-large-v3-ca-3catparla

STT Ca Citrinet 512

whisper-large-v3-ca-3catparla

ASR APIs

whisper-large-v3-ca-3catparla endpoint

example.py
import requests

API_URL = "https://ddb95svxi9vs16zy.us-east-1.aws.endpoints.huggingface.cloud"
headers = {
   "Accept": "application/json",
   "Authorization": "Bearer <hf_token>",
   "Content-Type": "audio/wav",
}


def query(filename):
   with open(filename, "rb") as f:
       data = f.read()
   response = requests.post(API_URL, headers=headers, data=data)
   return response.json()

output = query("sample1.wav")

faster-whisper endpoint

Python

example.py
import requests
API_URL = "https://l9w4uzm374uyn9xk.us-east-1.aws.endpoints.huggingface.cloud"
headers = {
  "Accept": "application/json",
  "Authorization": "Bearer HF_token",
  "Content-Type": "audio/wav",
}
def query(filename):
  with open(filename, "rb") as f:
      data = f.read()
  response = requests.post(API_URL, headers=headers, data=data)
  return response.json()
output = query("sample1.wav")

Curl

bash
curl "https://l9w4uzm374uyn9xk.us-east-1.aws.endpoints.huggingface.cloud/" \
-X POST \
--data-binary '@sample1.flac' \
-H "Accept: application/json" \
-H "Authorization: Bearer hf_XXXXX" \
-H "Content-Type: audio/flac" \// Some code

Citrinet endpoint

Python

example.py
import requests

API_URL = "https://h3xisjmpemyv68l1.us-east-1.aws.endpoints.huggingface.cloud/"
headers = {
   "Accept" : "application/json",
   "Authorization": "Bearer hf_xxxx",
   "Content-Type": "audio/wav"
}

def query(filename):
   with open(filename, "rb") as f:
       data = f.read()
   response = requests.post(API_URL, headers=headers, data=data)
   return response.json()

output = query("sample.wav")
print(output)

Possible issues with endpoints:

HTTP/1.1 401 Unauthorized: The Hugging Face token was not specified, or the token is invalid. Copy the token code and replace it where <hf_token> in the headers

HTTP/1.1 503: The service is unavailable. Occurs when the endpoint is initializing, as it is not active all the time. Try the same request again.

Last updated

© Projecte Aina | Language Technologies Unit at BSC