fixed text to speech
Browse files
app.py
CHANGED
|
@@ -118,19 +118,19 @@ class CancerApp:
|
|
| 118 |
# Create Flask API instance.
|
| 119 |
flask_app = Flask(__name__)
|
| 120 |
|
| 121 |
-
vectordb = vectorstore(path="data/PDF/Cancer The Evolutionary Legacy .pdf", Initlize_with=1)
|
| 122 |
-
print("done creating vectorstore")
|
| 123 |
-
vectordb.add_to_vectorstore_from_pdf("data/PDF/cancer_dictionary.pdf")
|
| 124 |
-
print("done adding cancer dictionary")
|
| 125 |
-
vectordb.add_to_vectorstore_from_pdf("data/PDF/Colon and Other GastrointestinalCancers.pdf")
|
| 126 |
-
print("done adding colon and other gastrointestinal cancers")
|
| 127 |
-
vectordb.add_to_vectorstore_from_pdf("data/PDF/Medical Dictionary.pdf")
|
| 128 |
-
print("done adding medical dictionary")
|
| 129 |
-
vectordb.add_to_vectorstore_from_pdf("data/PDF/Molecular biology of cancer.pdf")
|
| 130 |
-
print("done adding molecular biology of cancer")
|
| 131 |
-
vectordb.add_to_vectorstore_from_pdf("data/PDF/The biology of cancer.pdf")
|
| 132 |
-
print("done adding the biology of cancer")
|
| 133 |
-
print("finished vectorization")
|
| 134 |
|
| 135 |
vectordb_path = "VectorDB/vectorstore_mainV2"
|
| 136 |
cancer_app_instance = CancerApp(vectordb_path)
|
|
@@ -156,8 +156,10 @@ def api_text_to_speech():
|
|
| 156 |
message = data.get("message", "")
|
| 157 |
output_filename = data.get("output_filename", "output.wav")
|
| 158 |
saved_response = data.get("Saved_response", "")
|
|
|
|
| 159 |
saved_response = cancer_app_instance.text_to_speech(message, output_filename, Saved_response=saved_response)
|
| 160 |
-
|
|
|
|
| 161 |
|
| 162 |
# Endpoint for speech-to-text processing.
|
| 163 |
@flask_app.route('/speech_to_text', methods=['POST'])
|
|
@@ -191,4 +193,4 @@ def api_speech_to_speech():
|
|
| 191 |
return send_file(output_filename, as_attachment=True)
|
| 192 |
|
| 193 |
if __name__ == '__main__':
|
| 194 |
-
flask_app.run(host='0.0.0.0', port=7860, debug=True)
|
|
|
|
| 118 |
# Create Flask API instance.
|
| 119 |
flask_app = Flask(__name__)
|
| 120 |
|
| 121 |
+
# vectordb = vectorstore(path="data/PDF/Cancer The Evolutionary Legacy .pdf", Initlize_with=1)
|
| 122 |
+
# print("done creating vectorstore")
|
| 123 |
+
# vectordb.add_to_vectorstore_from_pdf("data/PDF/cancer_dictionary.pdf")
|
| 124 |
+
# print("done adding cancer dictionary")
|
| 125 |
+
# vectordb.add_to_vectorstore_from_pdf("data/PDF/Colon and Other GastrointestinalCancers.pdf")
|
| 126 |
+
# print("done adding colon and other gastrointestinal cancers")
|
| 127 |
+
# vectordb.add_to_vectorstore_from_pdf("data/PDF/Medical Dictionary.pdf")
|
| 128 |
+
# print("done adding medical dictionary")
|
| 129 |
+
# vectordb.add_to_vectorstore_from_pdf("data/PDF/Molecular biology of cancer.pdf")
|
| 130 |
+
# print("done adding molecular biology of cancer")
|
| 131 |
+
# vectordb.add_to_vectorstore_from_pdf("data/PDF/The biology of cancer.pdf")
|
| 132 |
+
# print("done adding the biology of cancer")
|
| 133 |
+
# print("finished vectorization")
|
| 134 |
|
| 135 |
vectordb_path = "VectorDB/vectorstore_mainV2"
|
| 136 |
cancer_app_instance = CancerApp(vectordb_path)
|
|
|
|
| 156 |
message = data.get("message", "")
|
| 157 |
output_filename = data.get("output_filename", "output.wav")
|
| 158 |
saved_response = data.get("Saved_response", "")
|
| 159 |
+
# Generate the WAV file from the text
|
| 160 |
saved_response = cancer_app_instance.text_to_speech(message, output_filename, Saved_response=saved_response)
|
| 161 |
+
# Return the file instead of JSON
|
| 162 |
+
return send_file(output_filename, mimetype="audio/wav", as_attachment=True)
|
| 163 |
|
| 164 |
# Endpoint for speech-to-text processing.
|
| 165 |
@flask_app.route('/speech_to_text', methods=['POST'])
|
|
|
|
| 193 |
return send_file(output_filename, as_attachment=True)
|
| 194 |
|
| 195 |
if __name__ == '__main__':
|
| 196 |
+
flask_app.run(host='0.0.0.0', port=7860, debug=True)
|