Spaces:
Build error
Build error
app.py
CHANGED
|
@@ -2,10 +2,12 @@ import gradio as gr
|
|
| 2 |
import ffmpeg
|
| 3 |
from pathlib import Path
|
| 4 |
import os
|
|
|
|
| 5 |
import json
|
| 6 |
import base64
|
| 7 |
import requests
|
| 8 |
-
|
|
|
|
| 9 |
|
| 10 |
API_URL = "https://api-inference.huggingface.co/models/facebook/wav2vec2-base-960h"
|
| 11 |
#headers = {"Authorization": "Bearer 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"}
|
|
@@ -26,6 +28,7 @@ def generate_transcripts(in_video): #generate_gifs(in_video, gif_transcript):
|
|
| 26 |
model_response = query_api(audio_memory)
|
| 27 |
|
| 28 |
#model response has both - transcripts as well as character timestamps or chunks
|
|
|
|
| 29 |
transcription = model_response["text"].lower()
|
| 30 |
chnk = model_response["chunks"]
|
| 31 |
|
|
@@ -77,6 +80,7 @@ def query_api(audio_bytes: bytes):
|
|
| 77 |
"""
|
| 78 |
Query for Huggingface Inference API for Automatic Speech Recognition task
|
| 79 |
"""
|
|
|
|
| 80 |
payload = json.dumps({
|
| 81 |
"inputs": base64.b64encode(audio_bytes).decode("utf-8"),
|
| 82 |
"parameters": {
|
|
@@ -90,6 +94,7 @@ def query_api(audio_bytes: bytes):
|
|
| 90 |
response = requests.request(
|
| 91 |
"POST", API_URL, headers=headers, data=payload)
|
| 92 |
json_reponse = json.loads(response.content.decode("utf-8"))
|
|
|
|
| 93 |
return json_reponse
|
| 94 |
|
| 95 |
|
|
|
|
| 2 |
import ffmpeg
|
| 3 |
from pathlib import Path
|
| 4 |
import os
|
| 5 |
+
import ast
|
| 6 |
import json
|
| 7 |
import base64
|
| 8 |
import requests
|
| 9 |
+
|
| 10 |
+
|
| 11 |
|
| 12 |
API_URL = "https://api-inference.huggingface.co/models/facebook/wav2vec2-base-960h"
|
| 13 |
#headers = {"Authorization": "Bearer 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"}
|
|
|
|
| 28 |
model_response = query_api(audio_memory)
|
| 29 |
|
| 30 |
#model response has both - transcripts as well as character timestamps or chunks
|
| 31 |
+
print(f"model_response is : {model_response}")
|
| 32 |
transcription = model_response["text"].lower()
|
| 33 |
chnk = model_response["chunks"]
|
| 34 |
|
|
|
|
| 80 |
"""
|
| 81 |
Query for Huggingface Inference API for Automatic Speech Recognition task
|
| 82 |
"""
|
| 83 |
+
print("********* Inside query_api() **********")
|
| 84 |
payload = json.dumps({
|
| 85 |
"inputs": base64.b64encode(audio_bytes).decode("utf-8"),
|
| 86 |
"parameters": {
|
|
|
|
| 94 |
response = requests.request(
|
| 95 |
"POST", API_URL, headers=headers, data=payload)
|
| 96 |
json_reponse = json.loads(response.content.decode("utf-8"))
|
| 97 |
+
print(f"json_reponse is :{json_reponse}")
|
| 98 |
return json_reponse
|
| 99 |
|
| 100 |
|