wisalkhanmv commited on
Commit
b218224
·
verified ·
1 Parent(s): 446e597

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from scipy.io.wavfile import write
3
+ from morse_tunes.morse import text_to_morse
4
+ from morse_tunes.audio import morse_to_numpy
5
+ import numpy as np
6
+
7
+ def convert_and_generate_audio(text):
8
+ """Converts text to Morse code and generates a NumPy audio array."""
9
+ morse_code = text_to_morse(text)
10
+ audio_data = morse_to_numpy(morse_code)
11
+ return morse_code, (44100, audio_data)
12
+
13
+ # Define the Gradio interface
14
+ interface = gr.Interface(
15
+ fn=convert_and_generate_audio,
16
+ inputs=gr.Textbox(label="Input Text", placeholder="Enter text to convert to Morse code"),
17
+ outputs=[
18
+ gr.Textbox(label="Morse Code"),
19
+ gr.Audio(label="Morse Code Audio", type="numpy"),
20
+ ],
21
+ title="MorseTunes",
22
+ description="Convert text to Morse code and generate audio that can be played in the browser.",
23
+ )
24
+
25
+ # Launch the Gradio app
26
+ if __name__ == "__main__":
27
+ interface.launch()