Amelia-James commited on
Commit
af12bd1
1 Parent(s): 1564098

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -23
app.py CHANGED
@@ -11,7 +11,7 @@ client = Groq(api_key=os.getenv("GROQ_API_KEY"))
11
 
12
  # Streamlit UI
13
  st.title("Voice Cloning Application")
14
- st.markdown("Clone your voice using Groq's Whisper Model and generate natural responses.")
15
 
16
  # Upload audio file
17
  uploaded_file = st.file_uploader(
@@ -24,34 +24,21 @@ if uploaded_file is not None:
24
  st.audio(uploaded_file, format=f"audio/{uploaded_file.type.split('.')[-1]}")
25
  st.write("Transcription in progress...")
26
 
27
- # Transcription Logic
 
 
28
  try:
29
- transcription = client.chat.completions.create(
30
- messages=[
31
- {
32
- "role": "user",
33
- "content": f"Transcribe the following audio file: {uploaded_file.name}"
34
- }
35
- ],
36
  model="whisper-large-v3-turbo",
 
37
  )
38
 
39
  # Display the transcription
40
- transcribed_text = transcription.choices[0].message.content
41
  st.success("Transcription completed!")
42
- st.write("**Transcribed Text:**", transcribed_text)
43
-
44
- # Placeholder for voice cloning (TTS integration can go here)
45
- st.markdown("---")
46
- st.subheader("Generate Speech from Transcription")
47
- tts_input = st.text_area("Enter text to generate speech:", value=transcribed_text)
48
-
49
- if st.button("Generate Speech"):
50
- if tts_input:
51
- # Simulate TTS functionality (placeholder for TTS model integration)
52
- st.success("Generated speech successfully! (Placeholder)")
53
- else:
54
- st.warning("Please enter some text.")
55
 
56
  except Exception as e:
57
  st.error(f"Error during transcription: {e}")
 
11
 
12
  # Streamlit UI
13
  st.title("Voice Cloning Application")
14
+ st.markdown("Clone your voice using Groq's Whisper Model for transcription.")
15
 
16
  # Upload audio file
17
  uploaded_file = st.file_uploader(
 
24
  st.audio(uploaded_file, format=f"audio/{uploaded_file.type.split('.')[-1]}")
25
  st.write("Transcription in progress...")
26
 
27
+ # Read file contents as binary
28
+ audio_bytes = uploaded_file.read()
29
+
30
  try:
31
+ # Transcription request to the Whisper model
32
+ transcription = client.audio.transcriptions.create(
33
+ file=audio_bytes,
 
 
 
 
34
  model="whisper-large-v3-turbo",
35
+ response_format="text", # Options: "text", "json"
36
  )
37
 
38
  # Display the transcription
 
39
  st.success("Transcription completed!")
40
+ st.write("**Transcribed Text:**")
41
+ st.text_area("Transcription", transcription, height=200)
 
 
 
 
 
 
 
 
 
 
 
42
 
43
  except Exception as e:
44
  st.error(f"Error during transcription: {e}")