geethareddy commited on
Commit
e215f5e
·
verified ·
1 Parent(s): f3d19de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -4,6 +4,7 @@ from transformers import pipeline
4
  from gtts import gTTS
5
  import os
6
  import re
 
7
 
8
  app = Flask(__name__)
9
 
@@ -27,9 +28,10 @@ prompts = {
27
  for key, text in prompts.items():
28
  generate_audio_prompt(text, f"{key}.mp3")
29
 
 
30
  SYMBOL_MAPPING = {
31
  "at the rate": "@",
32
- "at": "@", # Convert "at" to "@"
33
  "dot": ".",
34
  "underscore": "_",
35
  "hash": "#",
@@ -39,7 +41,7 @@ SYMBOL_MAPPING = {
39
  "space": " "
40
  }
41
 
42
- # Function to clean and replace symbols
43
  def clean_transcription(text):
44
  text = text.lower()
45
  for word, symbol in SYMBOL_MAPPING.items():
@@ -67,5 +69,6 @@ def transcribe():
67
  except Exception as e:
68
  return jsonify({"error": str(e)}), 500
69
 
 
70
  if __name__ == "__main__":
71
- app.run(host="0.0.0.0", port=5000, debug=True)
 
4
  from gtts import gTTS
5
  import os
6
  import re
7
+ from waitress import serve # Use Waitress for Production
8
 
9
  app = Flask(__name__)
10
 
 
28
  for key, text in prompts.items():
29
  generate_audio_prompt(text, f"{key}.mp3")
30
 
31
+ # Mapping for correctly converting spoken symbols to text
32
  SYMBOL_MAPPING = {
33
  "at the rate": "@",
34
+ "at": "@",
35
  "dot": ".",
36
  "underscore": "_",
37
  "hash": "#",
 
41
  "space": " "
42
  }
43
 
44
+ # Function to clean and process transcribed text
45
  def clean_transcription(text):
46
  text = text.lower()
47
  for word, symbol in SYMBOL_MAPPING.items():
 
69
  except Exception as e:
70
  return jsonify({"error": str(e)}), 500
71
 
72
+ # Run Waitress Server for Production
73
  if __name__ == "__main__":
74
+ serve(app, host="0.0.0.0", port=7860)