meraj12 commited on
Commit
ebc998d
·
verified ·
1 Parent(s): a3133a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -29
app.py CHANGED
@@ -1,37 +1,31 @@
1
-
2
  import os
 
3
 
4
- # Set up the folder where audio files will be saved
5
- UPLOAD_FOLDER = 'uploads/'
6
- os.makedirs(UPLOAD_FOLDER, exist_ok=True)
7
- app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
8
-
9
- # Allowed file extensions
10
- ALLOWED_EXTENSIONS = {'wav', 'mp3', 'ogg'}
11
 
12
- # Check if the file is allowed
13
- def allowed_file(filename):
14
- return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
15
 
16
- @app.route('/')
17
- def index():
18
- return render_template('index.html')
 
 
 
19
 
20
- @app.route('/upload', methods=['POST'])
21
- def upload_audio():
22
- if 'file' not in request.files:
23
- return jsonify({"message": "No file part"}), 400
24
 
25
- file = request.files['file']
26
- if file.filename == '':
27
- return jsonify({"message": "No selected file"}), 400
28
 
29
- if file and allowed_file(file.filename):
30
- filename = os.path.join(app.config['UPLOAD_FOLDER'], file.filename)
31
- file.save(filename)
32
- return jsonify({"message": "File uploaded successfully", "filename": file.filename}), 200
 
33
  else:
34
- return jsonify({"message": "Invalid file type. Only WAV, MP3, and OGG are allowed."}), 400
35
-
36
- if __name__ == "__main__":
37
- app.run(debug=True)
 
1
+ import streamlit as st
2
  import os
3
+ import requests
4
 
5
+ # Title for the Streamlit app
6
+ st.title("Voice Cloning Application")
 
 
 
 
 
7
 
8
+ # File uploader to upload a voice recording
9
+ uploaded_file = st.file_uploader("Upload a voice recording (First Time)", type=["wav", "mp3"])
 
10
 
11
+ if uploaded_file is not None:
12
+ # Save the uploaded file locally
13
+ with open("user_voice.wav", "wb") as f:
14
+ f.write(uploaded_file.getbuffer())
15
+
16
+ st.write("Your voice has been uploaded. Now we will clone your voice.")
17
 
18
+ # Simulate storing the voice in a "database" (for simplicity, store it in the file system)
19
+ user_voice_path = "user_voice.wav"
 
 
20
 
21
+ # You could use Groq or other ML acceleration API here to fine-tune the model
22
+ # Save user voice for future use (in real-life, this would be stored in a database)
23
+ st.write(f"Voice stored at {user_voice_path}")
24
 
25
+ # You can call your backend (Google Colab) to fine-tune the voice model
26
+ response = requests.post("https://your-colab-backend-url", files={"file": open(user_voice_path, "rb")})
27
+
28
+ if response.status_code == 200:
29
+ st.write("Voice fine-tuning completed successfully!")
30
  else:
31
+ st.write("Error in fine-tuning the voice.")