ValMar2024 commited on
Commit
f8b99f5
·
verified ·
1 Parent(s): 1017cb9

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -48
app.py DELETED
@@ -1,48 +0,0 @@
1
- import gradio as gr
2
- import openai
3
- import whisper
4
-
5
- # Setarea cheii OpenAI
6
- openai.api_key = "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"
7
-
8
- # Inițializare model Whisper
9
- model = whisper.load_model("base")
10
-
11
- # Funcția pentru procesarea audio-ului și generarea rezumatului
12
- def proceseaza_audio(file):
13
- # Verificăm dacă `file` este un obiect de tip fișier
14
- if hasattr(file, 'name'):
15
- file_path = file.name
16
- else:
17
- raise ValueError("Fișierul primit nu este valid. Verifică inputul.")
18
-
19
- # Transcriere folosind modelul Whisper
20
- result = model.transcribe(file_path)
21
- text = result["text"]
22
-
23
- # Generare rezumat folosind OpenAI
24
- response = openai.ChatCompletion.create(
25
- model="gpt-4",
26
- messages=[
27
- {"role": "system", "content": "Ești un asistent care rezumă textul."},
28
- {"role": "user", "content": text}
29
- ]
30
- )
31
- rezumat = response['choices'][0]['message']['content']
32
- return text, rezumat
33
-
34
- # Interfața Gradio
35
- inputs = gr.Audio(type="file")
36
- outputs = [gr.Textbox(label="Transcrierea textului:"), gr.Textbox(label="Rezumatul textului:")]
37
-
38
- app = gr.Interface(
39
- fn=proceseaza_audio,
40
- inputs=inputs,
41
- outputs=outputs,
42
- title="Transcriere și Rezumat AI",
43
- description="Această aplicație transcrie fișiere audio și creează un rezumat al conținutului folosind AI."
44
- )
45
-
46
- # Rulare aplicație
47
- if __name__ == "__main__":
48
- app.launch()