ValMar2024 commited on
Commit
da05775
·
verified ·
1 Parent(s): 2383de4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -41
app.py CHANGED
@@ -1,41 +1,41 @@
1
- import gradio as gr
2
- import openai
3
- import whisper
4
-
5
- # Load the Whisper model
6
- model = whisper.load_model("base")
7
-
8
- # Function to process audio and generate transcription and summary
9
- def procesare_audio(file):
10
- # Transcribe audio
11
- result = model.transcribe(file.name)
12
- transcriere_text = result["text"]
13
-
14
- # Use OpenAI to summarize the transcription
15
- openai.api_key = "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"
16
- response = openai.ChatCompletion.create(
17
- model="gpt-3.5-turbo",
18
- messages=[
19
- {"role": "system", "content": "You are a helpful assistant that summarizes text."},
20
- {"role": "user", "content": f"Please summarize the following text: {transcriere_text}"}
21
- ]
22
- )
23
- rezumat_text = response.choices[0].message.content.strip()
24
-
25
- return transcriere_text, rezumat_text
26
-
27
- # Define the Gradio interface
28
- interface = gr.Interface(
29
- fn=procesare_audio,
30
- inputs=gr.Audio(source="upload", type="file"),
31
- outputs=[
32
- gr.Textbox(label="Transcrierea textului:"),
33
- gr.Textbox(label="Rezumatul textului:")
34
- ],
35
- title="Transcriere și Rezumat AI",
36
- description="Această aplicație transcrie fișiere audio și creează un rezumat al conținutului folosind AI.",
37
- theme="compact"
38
- )
39
-
40
- # Launch the Gradio app
41
- interface.launch(share=False, debug=True)
 
1
+ import gradio as gr
2
+ import openai
3
+ import whisper
4
+
5
+ # Load the Whisper model
6
+ model = whisper.load_model("base")
7
+
8
+ # Function to process audio and generate transcription and summary
9
+ def procesare_audio(file):
10
+ # Transcribe audio
11
+ result = model.transcribe(file.name)
12
+ transcriere_text = result["text"]
13
+
14
+ # Use OpenAI to summarize the transcription
15
+ openai.api_key = "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"
16
+ response = openai.ChatCompletion.create(
17
+ model="gpt-3.5-turbo",
18
+ messages=[
19
+ {"role": "system", "content": "You are a helpful assistant that summarizes text."},
20
+ {"role": "user", "content": f"Please summarize the following text: {transcriere_text}"}
21
+ ]
22
+ )
23
+ rezumat_text = response.choices[0].message.content.strip()
24
+
25
+ return transcriere_text, rezumat_text
26
+
27
+ # Define the Gradio interface
28
+ interface = gr.Interface(
29
+ fn=procesare_audio,
30
+ inputs=gr.Audio(type="file")
31
+ outputs=[
32
+ gr.Textbox(label="Transcrierea textului:"),
33
+ gr.Textbox(label="Rezumatul textului:")
34
+ ],
35
+ title="Transcriere și Rezumat AI",
36
+ description="Această aplicație transcrie fișiere audio și creează un rezumat al conținutului folosind AI.",
37
+ theme="compact"
38
+ )
39
+
40
+ # Launch the Gradio app
41
+ interface.launch(share=False, debug=True)