Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,19 @@ import gradio as gr
|
|
| 5 |
|
| 6 |
openai.api_key = "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"
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
def transcribe(audio):
|
| 9 |
with open(audio, "rb") as audio_file:
|
| 10 |
transcript = openai.Audio.transcribe("whisper-1", audio_file)
|
|
|
|
| 5 |
|
| 6 |
openai.api_key = "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"
|
| 7 |
|
| 8 |
+
|
| 9 |
+
import requests
|
| 10 |
+
|
| 11 |
+
API_URL = "https://api-inference.huggingface.co/models/lyimo/whisper-small-sw2"
|
| 12 |
+
headers = {"Authorization": "Bearer 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"}
|
| 13 |
+
|
| 14 |
+
def query(filename):
|
| 15 |
+
with open(filename, "rb") as f:
|
| 16 |
+
data = f.read()
|
| 17 |
+
response = requests.post(API_URL, headers=headers, data=data)
|
| 18 |
+
return response.json()
|
| 19 |
+
|
| 20 |
+
|
| 21 |
def transcribe(audio):
|
| 22 |
with open(audio, "rb") as audio_file:
|
| 23 |
transcript = openai.Audio.transcribe("whisper-1", audio_file)
|