Spaces:
Sleeping
Sleeping
import os | |
import uuid | |
from flask import Flask, flash, render_template, request | |
from flask_cors import CORS | |
from modules import Module | |
model = Module() | |
app = Flask(__name__) | |
CORS(app) | |
app.secret_key = "Testing" | |
def index(): | |
flash(" Welcome to My Website") | |
return render_template('index.html') | |
def audio_to_text(): | |
flash(" Press Start to start recording audio and press Stop to end recording audio") | |
return render_template('audio_to_text.html') | |
def audio(): | |
try: | |
output_file = f"./tmp/{uuid.uuid4()}.wav" | |
open(output_file, 'wb').write(request.data) | |
text, emotion = model.predict(audio_path=output_file) | |
os.remove(output_file) | |
return_text = f" Transcription: {text} <br> Emotion: {emotion} " | |
except Exception: | |
return_text = " Sorry!!!! Voice not Detected " | |
return return_text | |
if __name__ == "__main__": | |
app.run(debug=True, port=7860, host='0.0.0.0') | |