Commit
·
793ea24
1
Parent(s):
087de2e
Update api_host.py
Browse files- api_host.py +13 -5
api_host.py
CHANGED
@@ -1,19 +1,22 @@
|
|
1 |
-
from flask import Flask, request, jsonify
|
2 |
-
from CircumSpect import answer_question, find_object_description, locate_object
|
3 |
from Perceptrix.engine import perceptrix, robotix, identify_objects_from_text, search_keyword
|
|
|
|
|
4 |
import numpy as np
|
5 |
-
import
|
6 |
import whisper
|
|
|
7 |
import os
|
8 |
|
9 |
model = whisper.load_model("base")
|
10 |
|
|
|
11 |
def transcribe(audio):
|
12 |
result = model.transcribe(audio)
|
13 |
transcription = result['text']
|
14 |
print(transcription)
|
15 |
return transcription
|
16 |
|
|
|
17 |
app = Flask(__name__)
|
18 |
|
19 |
|
@@ -120,7 +123,8 @@ def display_image():
|
|
120 |
|
121 |
except Exception as e:
|
122 |
return jsonify({'error': str(e)})
|
123 |
-
|
|
|
124 |
@app.route('/transcribe', methods=['POST'])
|
125 |
def upload_audio():
|
126 |
audio_file = request.files['audio']
|
@@ -130,5 +134,9 @@ def upload_audio():
|
|
130 |
return jsonify({'message': transcribe(filename)})
|
131 |
|
132 |
|
133 |
-
|
134 |
app.run()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from Perceptrix.engine import perceptrix, robotix, identify_objects_from_text, search_keyword
|
2 |
+
from CircumSpect import answer_question, find_object_description, locate_object
|
3 |
+
from flask import Flask, request, jsonify
|
4 |
import numpy as np
|
5 |
+
import threading
|
6 |
import whisper
|
7 |
+
import cv2
|
8 |
import os
|
9 |
|
10 |
model = whisper.load_model("base")
|
11 |
|
12 |
+
|
13 |
def transcribe(audio):
|
14 |
result = model.transcribe(audio)
|
15 |
transcription = result['text']
|
16 |
print(transcription)
|
17 |
return transcription
|
18 |
|
19 |
+
|
20 |
app = Flask(__name__)
|
21 |
|
22 |
|
|
|
123 |
|
124 |
except Exception as e:
|
125 |
return jsonify({'error': str(e)})
|
126 |
+
|
127 |
+
|
128 |
@app.route('/transcribe', methods=['POST'])
|
129 |
def upload_audio():
|
130 |
audio_file = request.files['audio']
|
|
|
134 |
return jsonify({'message': transcribe(filename)})
|
135 |
|
136 |
|
137 |
+
def run_app():
|
138 |
app.run()
|
139 |
+
|
140 |
+
if __name__ == "__main__":
|
141 |
+
runner = threading.Thread(target=run_app)
|
142 |
+
runner.start()
|