chburhan64 commited on
Commit
9c551fe
Β·
verified Β·
1 Parent(s): 8765707

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -9
app.py CHANGED
@@ -9,15 +9,19 @@ from gtts import gTTS
9
  import tempfile
10
  import pygame
11
  import streamlit as st
12
-
 
 
13
  # ==========================
14
  # πŸ” Secrets (set your own)
15
  # ==========================
16
- os.environ["GROQ_API_KEY"] = "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"
17
- os.environ["EMAIL_ADDRESS"] = "travis723452@gmail.com"
18
- os.environ["EMAIL_PASSWORD"] = "tcfmyngdfcwoczia"
19
 
20
- client = Groq(api_key=os.environ["GROQ_API_KEY"])
 
 
 
 
21
  whisper_model = whisper.load_model("base")
22
 
23
  # ==========================
@@ -104,10 +108,19 @@ def speak_and_download(text, lang="en"):
104
  # ==========================
105
  # πŸ“œ Whisper Transcriber
106
  # ==========================
107
- def transcribe_audio(file_path):
108
- result = whisper_model.transcribe(file_path)
109
- return result["text"]
110
-
 
 
 
 
 
 
 
 
 
111
  # ==========================
112
  # πŸš€ Streamlit Interface
113
  # ==========================
 
9
  import tempfile
10
  import pygame
11
  import streamlit as st
12
+ from dotenv import load_dotenv
13
+ import os
14
+ import threading
15
  # ==========================
16
  # πŸ” Secrets (set your own)
17
  # ==========================
18
+ load_dotenv()
 
 
19
 
20
+ GROQ_API_KEY = os.getenv("GROQ_API_KEY")
21
+ EMAIL_ADDRESS = os.getenv("EMAIL_ADDRESS")
22
+ EMAIL_PASSWORD = os.getenv("EMAIL_PASSWORD")
23
+
24
+ client = Groq(api_key=GROQ_API_KEY)
25
  whisper_model = whisper.load_model("base")
26
 
27
  # ==========================
 
108
  # ==========================
109
  # πŸ“œ Whisper Transcriber
110
  # ==========================
111
+ def transcribe_audio(file):
112
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as temp_wav:
113
+ if file.name.endswith(".mp3"):
114
+ audio = AudioSegment.from_mp3(file)
115
+ elif file.name.endswith(".wav"):
116
+ audio = AudioSegment.from_wav(file)
117
+ else:
118
+ st.error("Unsupported file type.")
119
+ return ""
120
+
121
+ audio.export(temp_wav.name, format="wav")
122
+ result = whisper_model.transcribe(temp_wav.name)
123
+ return result["text"]
124
  # ==========================
125
  # πŸš€ Streamlit Interface
126
  # ==========================