Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import requests
|
3 |
+
from io import BytesIO
|
4 |
+
|
5 |
+
# Title of the app
|
6 |
+
st.title('Voice Cloning App')
|
7 |
+
|
8 |
+
# File uploader widget for uploading the voice recording
|
9 |
+
uploaded_file = st.file_uploader("Upload an audio file (MP3, WAV)", type=['mp3', 'wav'])
|
10 |
+
|
11 |
+
# Function to send audio file to the backend (Google Colab)
|
12 |
+
def send_to_backend(audio_file):
|
13 |
+
# Make sure your Google Colab or API is set up to accept POST requests with audio data
|
14 |
+
url = 'import streamlit as st
|
15 |
+
import requests
|
16 |
+
from io import BytesIO
|
17 |
+
|
18 |
+
# Title of the app
|
19 |
+
st.title('Voice Cloning App')
|
20 |
+
|
21 |
+
# File uploader widget for uploading the voice recording
|
22 |
+
uploaded_file = st.file_uploader("Upload an audio file (MP3, WAV)", type=['mp3', 'wav'])
|
23 |
+
|
24 |
+
# Function to send audio file to the backend (Google Colab)
|
25 |
+
def send_to_backend(audio_file):
|
26 |
+
# Make sure your Google Colab or API is set up to accept POST requests with audio data
|
27 |
+
url = '>' # replace with your backend API URL
|
28 |
+
files = {'file': audio_file}
|
29 |
+
response = requests.post(url, files=files)
|
30 |
+
return response
|
31 |
+
|
32 |
+
# Display the uploaded file and send it for processing
|
33 |
+
if uploaded_file is not None:
|
34 |
+
st.audio(uploaded_file, format='audio/wav')
|
35 |
+
|
36 |
+
# Process the file and return the cloned voice (assuming backend returns a file URL or the file itself)
|
37 |
+
with st.spinner("Processing..."):
|
38 |
+
result = send_to_backend(uploaded_file)
|
39 |
+
if result.status_code == 200:
|
40 |
+
# If the result is successful, display the cloned audio
|
41 |
+
st.success('Voice cloned successfully!')
|
42 |
+
st.audio(result.content, format='audio/wav')
|
43 |
+
else:
|
44 |
+
st.error("Error in processing the voice cloning. Please try again.")
|
45 |
+
>' # replace with your backend API URL
|
46 |
+
files = {'file': audio_file}
|
47 |
+
response = requests.post(url, files=files)
|
48 |
+
return response
|
49 |
+
|
50 |
+
# Display the uploaded file and send it for processing
|
51 |
+
if uploaded_file is not None:
|
52 |
+
st.audio(uploaded_file, format='audio/wav')
|
53 |
+
|
54 |
+
# Process the file and return the cloned voice (assuming backend returns a file URL or the file itself)
|
55 |
+
with st.spinner("Processing..."):
|
56 |
+
result = send_to_backend(uploaded_file)
|
57 |
+
if result.status_code == 200:
|
58 |
+
# If the result is successful, display the cloned audio
|
59 |
+
st.success('Voice cloned successfully!')
|
60 |
+
st.audio(result.content, format='audio/wav')
|
61 |
+
else:
|
62 |
+
st.error("Error in processing the voice cloning. Please try again.")
|