jcockhren commited on
Commit
3a16d68
·
verified ·
1 Parent(s): 14060bd

Added query callable

Browse files
Files changed (1) hide show
  1. app.py +22 -3
app.py CHANGED
@@ -1,6 +1,11 @@
1
  import numpy as np
2
  import gradio as gr
3
 
 
 
 
 
 
4
  def sepia(input_img):
5
  sepia_filter = np.array([
6
  [0.393, 0.769, 0.189],
@@ -11,7 +16,21 @@ def sepia(input_img):
11
  sepia_img /= sepia_img.max()
12
  return sepia_img
13
 
14
- demo = gr.Interface(gr.Dropdown(choices=["First Choice", "Second Choice", "Third Choice"]),
15
- gr.Image(),
16
- "image")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  demo.launch()
 
1
  import numpy as np
2
  import gradio as gr
3
 
4
+ PROVIDERMODEL = {
5
+ 'openai': 'openai/whisper-medium.en',
6
+ 'facebook': 'facebook/wav2vec2-base-960h',
7
+ }
8
+
9
  def sepia(input_img):
10
  sepia_filter = np.array([
11
  [0.393, 0.769, 0.189],
 
16
  sepia_img /= sepia_img.max()
17
  return sepia_img
18
 
19
+
20
+ def query(filename, provider='openai'):
21
+ with open(filename, "rb") as f:
22
+ data = f.read()
23
+ API_URL = f"https://api-inference.huggingface.co/models/{PROVIDERMODEL[provider]}"
24
+ headers = {"Authorization": f"Bearer {API_TOKEN}"}
25
+ response = requests.request("POST", API_URL, headers=headers, data=data)
26
+ if response.status_code == 200:
27
+ return json.loads(response.content.decode("utf-8"))
28
+ else:
29
+ return {"error": response.content}
30
+
31
+
32
+
33
+ demo = gr.Interface(
34
+ gr.Dropdown(choices=["First Choice", "Second Choice", "Third Choice"]),
35
+ "text")
36
  demo.launch()