tsi-org commited on
Commit
c2c2101
·
verified ·
1 Parent(s): ba40e2e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -22
app.py CHANGED
@@ -5,12 +5,15 @@ from groq import Groq
5
  # Predefined password
6
  CORRECT_PASSWORD = "password123"
7
 
8
- def process_input(password, api_key, audio_file):
9
- if password != CORRECT_PASSWORD:
10
- return "Incorrect password. Please try again.", "", ""
 
 
 
11
 
12
  if not api_key or not audio_file:
13
- return "Password correct. Please enter your API key and upload an audio file.", "", ""
14
 
15
  try:
16
  client = Groq(api_key=api_key)
@@ -21,32 +24,20 @@ def process_input(password, api_key, audio_file):
21
  temperature=1,
22
  response_format="verbose_json",
23
  )
24
- return "Transcription successful", transcription.text, ""
25
  except Exception as e:
26
- return f"An error occurred: {str(e)}", "", ""
27
 
28
- # Create the interface
29
  iface = gr.Interface(
30
- fn=process_input,
31
  inputs=[
32
  gr.Textbox(type="password", label="Password"),
33
  gr.Textbox(label="Groq API Key", type="password"),
34
  gr.File(label="Upload Audio File")
35
  ],
36
- outputs=[
37
- gr.Textbox(label="Status"),
38
- gr.Textbox(label="Transcribed Text"),
39
- gr.Audio(label="Audio File") # This will display the uploaded audio file
40
- ],
41
- title="Audio Transcription App",
42
- description="""
43
- How to use this app:
44
- 1. Enter the correct password.
45
- 2. Enter your Groq API Key.
46
- 3. Upload a supported audio file (mp3, mp4, mpeg, mpga, m4a, wav, or webm).
47
- 4. Click "Submit" to transcribe your speech.
48
- 5. The transcription will appear in the "Transcribed Text" box.
49
- """
50
  )
51
 
52
  if __name__ == "__main__":
 
5
  # Predefined password
6
  CORRECT_PASSWORD = "password123"
7
 
8
+ def check_password(password):
9
+ return password == CORRECT_PASSWORD
10
+
11
+ def transcribe_audio(password, api_key, audio_file):
12
+ if not check_password(password):
13
+ return "Incorrect password. Access denied."
14
 
15
  if not api_key or not audio_file:
16
+ return "Please provide both API key and audio file."
17
 
18
  try:
19
  client = Groq(api_key=api_key)
 
24
  temperature=1,
25
  response_format="verbose_json",
26
  )
27
+ return transcription.text
28
  except Exception as e:
29
+ return f"An error occurred: {str(e)}"
30
 
 
31
  iface = gr.Interface(
32
+ fn=transcribe_audio,
33
  inputs=[
34
  gr.Textbox(type="password", label="Password"),
35
  gr.Textbox(label="Groq API Key", type="password"),
36
  gr.File(label="Upload Audio File")
37
  ],
38
+ outputs=gr.Textbox(label="Result"),
39
+ title="Password Protected Audio Transcription App",
40
+ description="Enter the correct password to access the app. Then provide your Groq API key and upload an audio file to transcribe."
 
 
 
 
 
 
 
 
 
 
 
41
  )
42
 
43
  if __name__ == "__main__":