sanjay7178 commited on
Commit
699b0d1
·
verified ·
1 Parent(s): 74925a6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ from flask import Flask, render_template, request
3
+
4
+ app = Flask(__name__)
5
+
6
+ def process_ssml_text(ssml_text):
7
+ """
8
+ Process SSML text to extract content between SSML tags and format it properly.
9
+ """
10
+ # Regular expression to find all textnorm tags and their content
11
+ result = []
12
+
13
+ # Process each line separately
14
+ lines = ssml_text.split('\n')
15
+
16
+ for line in lines:
17
+ # Create a new line by removing all SSML tags and just using the clean text
18
+ clean_line = re.sub(r'<textnorm[^>]*>([^<]*)</textnorm>', r'\1', line)
19
+
20
+ # Replace specific symbols to match the expected output
21
+ clean_line = clean_line.replace('A☼M', 'A※M').replace('P☼M', 'P※M')
22
+
23
+ result.append(clean_line)
24
+
25
+ return '\n'.join(result)
26
+
27
+ @app.route('/', methods=['GET', 'POST'])
28
+ def index():
29
+ processed_text = ""
30
+ input_text = ""
31
+
32
+ if request.method == 'POST':
33
+ input_text = request.form.get('input_text', '')
34
+ processed_text = process_ssml_text(input_text)
35
+
36
+ return render_template('index.html', processed_text=processed_text, input_text=input_text)
37
+
38
+ if __name__ == '__main__':
39
+ app.run(debug=True)