Kamtera commited on
Commit
4a684d4
1 Parent(s): d3e1b2e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +80 -5
app.py CHANGED
@@ -5,9 +5,82 @@ import os
5
  import speech_recognition as sr
6
 
7
 
8
- html_seeker='''
9
- <html> <head> <meta charset="utf-8" /> <title>Gentle</title> <style> html, body { margin: 0; padding: 0; min-width: 900px; } #header { position: fixed; top: 0; left: 0; height: 50px; min-width: 900px; line-height: 50px; width: 100%; background-color: #999; box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.5); font-family: Helvetica, sans-serif; } #header, #header a { color: white; } .home { margin: 0; font-weight: bold; text-transform: lowercase; width: 100px; } h4.home { margin: 0; background: #666; padding-left: 25px; padding-right: 30px; margin-right: 20px; float: left; text-decoration: none; } .home:hover a { background: #555; } #audio { margin-top: 9px; width: 500px; display: inline-block; } #transcript { margin: 0 15px; margin-bottom: 5em; white-space: pre-wrap; line-height: 2em; max-width: 600px; color: #999; clear: both; margin-top: 75px; /*direction: rtl;*/ } .success { color: black; } .success:hover { text-decoration: underline; } .active { color: magenta; background-color: yellow; } #preloader { visibility: hidden; } </style> </head> <body> <div id="header"> <h4 class="home">Model name</h4>'''
10
- html_seeker1='''</div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  </div>
12
 
13
 
@@ -17,6 +90,7 @@ html_seeker1='''</div>
17
  <script>
18
 
19
  var $a = document.querySelector("audio");
 
20
  window.onkeydown = function(ev) {
21
  if(ev.keyCode == 32) {
22
  ev.preventDefault();
@@ -97,7 +171,8 @@ function update() {
97
  }
98
 
99
  var INLINE_JSON='''
100
- html_seeker2=''';update();
 
101
  </script>'''
102
  '''
103
  model_name = "voidful/wav2vec2-xlsr-multilingual-56"
@@ -122,7 +197,7 @@ def predict_fa(speech,model):
122
  text = model0(speech,return_timestamps="word" )
123
  '''
124
  text={"text": "\u0627\u06cc\u0646\u0627\u0646 \u06a9\u0631\u0627\u0644\u0627\u0644 \u0648 \u06a9\u0648\u0631\u0646\u062f \u0648 \u0644\u0632\u0627 \u0627\u0632 \u06af\u0645\u0631\u0627\u0647\u06cc \u0628\u0647 \u0631\u0627\u0647 \u0628\u0627\u0632 \u0646\u0645\u06cc\u06a9\u0631\u062f\u0646\u062f", "chunks": [{"text": "\u0627\u06cc\u0646\u0627\u0646", "timestamp": [0.0, 0.72]}, {"text": "\u06a9\u0631\u0627\u0644\u0627\u0644", "timestamp": [0.92, 1.6]}, {"text": "\u0648", "timestamp": [1.72, 1.74]}, {"text": "\u06a9\u0648\u0631\u0646\u062f", "timestamp": [1.9, 2.54]}, {"text": "\u0648", "timestamp": [2.76, 2.78]}, {"text": "\u0644\u0632\u0627", "timestamp": [2.88, 3.16]}, {"text": "\u0627\u0632", "timestamp": [3.4, 3.5]}, {"text": "\u06af\u0645\u0631\u0627\u0647\u06cc", "timestamp": [3.64, 4.3]}, {"text": "\u0628\u0647", "timestamp": [4.6, 4.68]}, {"text": "\u0631\u0627\u0647", "timestamp": [4.78, 5.12]}, {"text": "\u0628\u0627\u0632", "timestamp": [5.3, 5.58]}, {"text": "\u0646\u0645\u06cc\u06a9\u0631\u062f\u0646\u062f", "timestamp": [5.68, 7.14]}]}
125
- return [text['text'],json.dumps(text),html_seeker+speech+html_seeker1+json.dumps(text)+html_seeker2]
126
 
127
 
128
  def convert_to_wav(filename):
 
5
  import speech_recognition as sr
6
 
7
 
8
+ html_seeker='''<style>
9
+ html, body {
10
+ margin: 0;
11
+ padding: 0;
12
+ min-width: 900px;
13
+ }
14
+ #header {
15
+ /*position: fixed;*/
16
+ top: 0;
17
+ left: 0;
18
+ height: 50px;
19
+ min-width: 900px;
20
+ line-height: 50px;
21
+ width: 100%;
22
+ background-color: #999;
23
+ box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.5);
24
+ font-family: Helvetica, sans-serif;
25
+ }
26
+ #header, #header a {
27
+ color: white;
28
+ }
29
+
30
+ .home {
31
+ margin: 0;
32
+ font-weight: bold;
33
+ text-transform: lowercase;
34
+ width: 100px;
35
+ }
36
+ h4.home {
37
+ margin: 0;
38
+ background: #666;
39
+ padding-left: 25px;
40
+ padding-right: 30px;
41
+ margin-right: 20px;
42
+ float: left;
43
+ text-decoration: none;
44
+ }
45
+ .home:hover a {
46
+ background: #555;
47
+ }
48
+ #audio {
49
+ margin-top: 9px;
50
+ width: 500px;
51
+ display: inline-block;
52
+ }
53
+ #transcript {
54
+ margin: 0 15px;
55
+ margin-bottom: 5em;
56
+ white-space: pre-wrap;
57
+ line-height: 2em;
58
+ max-width: 600px;
59
+ color: #999;
60
+ clear: both;
61
+ margin-top: 75px;
62
+ /*direction: rtl;*/
63
+ }
64
+ .success {
65
+ color: black;
66
+
67
+ }
68
+ .success:hover {
69
+ text-decoration: underline;
70
+ }
71
+ .active {
72
+ color: magenta;
73
+ background-color: yellow;
74
+ }
75
+ #preloader {
76
+ visibility: hidden;
77
+ }
78
+
79
+
80
+ </style><div id="header">
81
+ <h4 class="home">Model name</h4>
82
+ <audio id="audio" src="17.mp3" controls="true"></audio>
83
+ </div>
84
  </div>
85
 
86
 
 
90
  <script>
91
 
92
  var $a = document.querySelector("audio");
93
+ $a.src=document.querySelector('audio').src;
94
  window.onkeydown = function(ev) {
95
  if(ev.keyCode == 32) {
96
  ev.preventDefault();
 
171
  }
172
 
173
  var INLINE_JSON='''
174
+ html_seeker2=''';
175
+ update();
176
  </script>'''
177
  '''
178
  model_name = "voidful/wav2vec2-xlsr-multilingual-56"
 
197
  text = model0(speech,return_timestamps="word" )
198
  '''
199
  text={"text": "\u0627\u06cc\u0646\u0627\u0646 \u06a9\u0631\u0627\u0644\u0627\u0644 \u0648 \u06a9\u0648\u0631\u0646\u062f \u0648 \u0644\u0632\u0627 \u0627\u0632 \u06af\u0645\u0631\u0627\u0647\u06cc \u0628\u0647 \u0631\u0627\u0647 \u0628\u0627\u0632 \u0646\u0645\u06cc\u06a9\u0631\u062f\u0646\u062f", "chunks": [{"text": "\u0627\u06cc\u0646\u0627\u0646", "timestamp": [0.0, 0.72]}, {"text": "\u06a9\u0631\u0627\u0644\u0627\u0644", "timestamp": [0.92, 1.6]}, {"text": "\u0648", "timestamp": [1.72, 1.74]}, {"text": "\u06a9\u0648\u0631\u0646\u062f", "timestamp": [1.9, 2.54]}, {"text": "\u0648", "timestamp": [2.76, 2.78]}, {"text": "\u0644\u0632\u0627", "timestamp": [2.88, 3.16]}, {"text": "\u0627\u0632", "timestamp": [3.4, 3.5]}, {"text": "\u06af\u0645\u0631\u0627\u0647\u06cc", "timestamp": [3.64, 4.3]}, {"text": "\u0628\u0647", "timestamp": [4.6, 4.68]}, {"text": "\u0631\u0627\u0647", "timestamp": [4.78, 5.12]}, {"text": "\u0628\u0627\u0632", "timestamp": [5.3, 5.58]}, {"text": "\u0646\u0645\u06cc\u06a9\u0631\u062f\u0646\u062f", "timestamp": [5.68, 7.14]}]}
200
+ return [text['text'],json.dumps(text),html_seeker+json.dumps(text)+html_seeker2]
201
 
202
 
203
  def convert_to_wav(filename):