can run speechtotext server
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import os
|
||||
import uuid
|
||||
|
||||
from flask import Flask
|
||||
from flask import jsonify
|
||||
from flask import request
|
||||
from flask_cors import CORS, cross_origin
|
||||
|
||||
from src.workers.SpeechToText import SpeechToText
|
||||
|
||||
app = Flask(__name__)
|
||||
cors = CORS(app)
|
||||
app.config['CORS_HEADERS'] = 'Content-Type'
|
||||
|
||||
|
||||
@app.route('/', methods=['POST'])
|
||||
@cross_origin()
|
||||
def post():
|
||||
file_name = str(uuid.uuid4()) + ".wav"
|
||||
with open(file_name, "wb") as vid:
|
||||
vid.write(request.data)
|
||||
speech_to_text = SpeechToText()
|
||||
result = speech_to_text.to_text(file_name)
|
||||
try:
|
||||
os.remove(file_name)
|
||||
except OSError:
|
||||
print(OSError)
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0', port=8000, debug=True)
|
||||
Reference in New Issue
Block a user