Ifeanyi commited on
Commit
84745c0
·
verified ·
1 Parent(s): e75b015

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -32
app.py CHANGED
@@ -1,33 +1,38 @@
1
- import google.generativeai as genai
2
  import gradio as gr
3
- import numpy as np
4
- import PIL.Image
5
- import os
6
-
7
- gemini_api_key = os.getenv("GEMINI_API_KEY")
8
- genai.configure(api_key=gemini_api_key)
9
-
10
- def ImageChat(image, prompt):
11
-
12
- # load model
13
- model = genai.GenerativeModel("gemini-1.5-flash")
14
-
15
- # check image file and convert to a Numpy array
16
- if isinstance(image, np.ndarray):
17
-
18
- img = PIL.Image.fromarray(image)
19
- else:
20
- img = PIL.Image.open(image)
21
-
22
- response = model.generate_content([prompt, img])
23
-
24
- return response.text
25
-
26
-
27
- app = gr.Interface(ImageChat,
28
- inputs = [gr.Image(label = "Image"), gr.Text(label = "Prompt")],
29
- outputs = gr.Text(label = "Response"),
30
- title = "Image Chat",
31
- theme = "Taithrah/Minimal")
32
-
33
- app.launch()
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import assemblyai as aai
3
+ import google.generativeai as genai
4
+ from script import audioTranscribe
5
+
6
+ # app = gr.Interface(audioTranscribe,
7
+ # inputs=[gr.Audio(sources=["microphone"], type="filepath"),
8
+ # gr.Dropdown(["French","Spanish","German","Italian","Japanese"],
9
+ # label="Languages",
10
+ # multiselect=False,
11
+ # value="French",
12
+ # info="Translations")],
13
+ # outputs=[gr.Text(label="Transcription"),gr.Text(label="Translation")])
14
+ # app.launch(debug=True)
15
+
16
+ with gr.Blocks(theme = gr.themes.Soft()) as app:
17
+ gr.Markdown("<center><strong><h3>Audio Transcription & Translation</h3></strong></center>")
18
+ with gr.Column():
19
+ with gr.Row():
20
+ audio_file = gr.Audio(sources=["microphone"], type="filepath")
21
+ translation = gr.Radio(choices=["French","Spanish","German","Italian","Japanese","Portuguese","Igbo","Korean","Hindi","Yoruba","Dutch","Hausa","Polish","Swahili","Turkish"],
22
+ label="Select Translate-To Language",
23
+ value="French",
24
+ interactive=True)
25
+ with gr.Row():
26
+ btn = gr.Button("Transcribe & Translate")
27
+ clear_btn = gr.ClearButton(value="Clear")
28
+ with gr.Column():
29
+ gr.Markdown("<center><strong><h3>Transcription & Translation Output</h3></strong></center>")
30
+ with gr.Row():
31
+ transcription = gr.Text(label="Transcription")
32
+ translation_text = gr.Text(label="Translation")
33
+
34
+
35
+ btn.click(audioTranscribe, inputs=[audio_file,translation], outputs=[transcription,translation_text])
36
+ clear_btn.click(lambda: (None, "French", "", ""), inputs=[], outputs=[audio_file, translation, transcription, translation_text], queue=False)
37
+
38
+ app.launch()