Spaces:
Sleeping
Sleeping
Delete app.py
Browse files
app.py
DELETED
@@ -1,39 +0,0 @@
|
|
1 |
-
import openai
|
2 |
-
import whisper
|
3 |
-
import gradio as gr
|
4 |
-
|
5 |
-
# Setarea cheii API OpenAI
|
6 |
-
openai.api_key = "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" # Înlocuiește cu cheia ta reală OpenAI
|
7 |
-
|
8 |
-
# Încarcă modelul Whisper
|
9 |
-
model = whisper.load_model("base")
|
10 |
-
|
11 |
-
# Funcția pentru procesarea fișierului audio
|
12 |
-
def proceseaza_audio(file):
|
13 |
-
# Transcriere audio folosind Whisper
|
14 |
-
result = model.transcribe(file.name)
|
15 |
-
text_transcris = result["text"]
|
16 |
-
|
17 |
-
# Rezumat generat de OpenAI
|
18 |
-
response = openai.ChatCompletion.create(
|
19 |
-
model="gpt-3.5-turbo",
|
20 |
-
messages=[
|
21 |
-
{"role": "system", "content": "Rezumă textul următor în mod concis."},
|
22 |
-
{"role": "user", "content": text_transcris},
|
23 |
-
]
|
24 |
-
)
|
25 |
-
rezumat = response['choices'][0]['message']['content']
|
26 |
-
return text_transcris, rezumat
|
27 |
-
|
28 |
-
# Interfața Gradio
|
29 |
-
inputs = gr.Audio(source="upload", type="numpy")
|
30 |
-
outputs = [gr.Textbox(label="Transcrierea textului"), gr.Textbox(label="Rezumatul textului")]
|
31 |
-
|
32 |
-
# Lansează aplicația
|
33 |
-
gr.Interface(
|
34 |
-
fn=proceseaza_audio,
|
35 |
-
inputs=inputs,
|
36 |
-
outputs=outputs,
|
37 |
-
title="Transcriere și Rezumat AI",
|
38 |
-
description="Această aplicație transcrie fișiere audio și creează un rezumat al conținutului folosind AI."
|
39 |
-
).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|