LaynzID12's picture
Create app.py
f350579 verified
raw
history blame contribute delete
No virus
870 Bytes
import gradio as gr
import os
# Function to record and save the audio
def record_sound(audio):
# Save the audio to a file
audio_path = "recorded_audio.wav"
audio['file'].save(audio_path)
return audio_path
# Function to play the audio back
def play_sound(audio_file):
# Return the path to the recorded audio file for playback
return audio_file
# Create Gradio interface with a microphone input and an audio output
iface = gr.Interface(
fn=record_sound, # Function that records audio
inputs=gr.Audio(source='microphone', type='filepath'), # Microphone input
outputs=gr.Audio(type='file'), # Output to play back recorded audio
title="Sound Recorder", # Title of the interface
description="Record audio from your microphone and play it back." # Description of the interface
)
# Launch the Gradio interface
iface.launch()