elina12 commited on
Commit
4152f94
1 Parent(s): 980471d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -35
app.py CHANGED
@@ -1,37 +1,3 @@
1
-
2
- import sys
3
- import requests
4
- import re
5
- import os
6
- import base64
7
  import gradio as gr
8
- api_token1="Bearer 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"
9
- headers1= {"Authorization":api_token1}
10
-
11
- API_URL = "https://api-inference.huggingface.co/models/jonatasgrosman/wav2vec2-large-xlsr-53-arabic"
12
-
13
- def query(filename):
14
- with open(filename, "rb") as f:
15
- data = f.read()
16
-
17
- # Convert bytes to base64-encoded string
18
- encoded_data = base64.b64encode(data).decode()
19
- options = {"wait_for_model": True} # Set wait_for_model parameter to True
20
- payload = {"inputs": encoded_data, "options": options}
21
- response = requests.post(API_URL, headers=headers1, json=payload)
22
-
23
- return response.json()
24
-
25
- def process_audio(filename):
26
- response = query(filename)
27
- o1 = response['text']
28
- return o1
29
- # Define the Gradio interface
30
- demo = gr.Interface(
31
- fn=process_audio,
32
- inputs=gr.inputs.Audio(source="upload", type="filepath"),
33
- outputs="text"
34
- )
35
 
36
- # Launch the Gradio interface
37
- demo.launch()
 
 
 
 
 
 
 
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ gr.Interface.load("models/jonatasgrosman/wav2vec2-large-xlsr-53-arabic").launch()