shubham13spd commited on
Commit
dc821ee
·
1 Parent(s): 74f7ad7

Update app

Browse files
Files changed (2) hide show
  1. .gitignore +2 -0
  2. app.py +43 -3
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .env
2
+ output.mp3
app.py CHANGED
@@ -1,6 +1,46 @@
1
  import gradio as gr
 
 
2
 
3
- def greet(name):
4
- return f"Hello {name}!"
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from pydub import AudioSegment
3
+ import os
4
 
5
+ def change_audio_speed(audio_file, speed):
6
+ if not audio_file:
7
+ return "Please upload an audio file."
8
 
9
+ try:
10
+ # Load the audio file
11
+ print("inside try of audio call")
12
+ audio = AudioSegment.from_file(audio_file, format="wav")
13
+
14
+ # Modify speed
15
+ new_audio = audio._spawn(audio.raw_data, overrides={
16
+ "frame_rate": int(audio.frame_rate * speed)
17
+ }).set_frame_rate(audio.frame_rate)
18
+
19
+ # Save the processed file
20
+ output_path = "output.mp3"
21
+ new_audio.export(output_path, format="mp3")
22
+
23
+ return output_path
24
+
25
+ except Exception as e:
26
+ print("inside except of audio call", str(e))
27
+ return str(e)
28
+
29
+ # Gradio UI
30
+ with gr.Blocks() as demo:
31
+ gr.Markdown("# 🎵 Audio Speed Modifier with ElevenLabs API Key Input")
32
+
33
+ with gr.Row():
34
+ audio_input = gr.File(label="Upload MP3 Audio")
35
+ api_key = gr.Textbox(label="Enter ElevenLabs API Key", type="password")
36
+
37
+ speed_slider = gr.Slider(0.5, 3.0, 1.2, step=0.1, label="Speed Factor (1.2x = 20% faster)")
38
+
39
+ output_audio = gr.Audio(label="Processed Audio", type="filepath")
40
+
41
+ process_button = gr.Button("Process Audio")
42
+
43
+ process_button.click(change_audio_speed, inputs=[audio_input, speed_slider], outputs=output_audio)
44
+
45
+
46
+ demo.launch(debug=True)