johnpaulbin commited on
Commit
1e6726d
·
verified ·
1 Parent(s): c4305a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py CHANGED
@@ -45,6 +45,16 @@ def home():
45
  <h1>Speech Recognition</h1>
46
  <button id="start">Start Listening</button>
47
  <button id="stop">Stop Listening</button>
 
 
 
 
 
 
 
 
 
 
48
  <div>
49
  <label for="username">Username:</label>
50
  <input type="text" id="username" placeholder="Enter your username">
@@ -55,11 +65,28 @@ def home():
55
  if (!window.SpeechRecognition) {
56
  alert("Your browser does not support Speech Recognition. Try Google Chrome.");
57
  }
 
 
58
  let recognition = new window.SpeechRecognition();
59
  recognition.continuous = true;
60
  recognition.interimResults = true;
61
  let liveOutput = document.getElementById('transcription');
62
  let lastTranscription = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
  recognition.onresult = (event) => {
65
  let currentTranscription = '';
 
45
  <h1>Speech Recognition</h1>
46
  <button id="start">Start Listening</button>
47
  <button id="stop">Stop Listening</button>
48
+ <div>
49
+ <label for="language">Language:</label>
50
+ <select id="language">
51
+ <option value="en-US">English (US)</option>
52
+ <option value="es-ES">Spanish (Spain)</option>
53
+ <option value="fr-FR">French</option>
54
+ <!-- Add more languages as needed -->
55
+ </select>
56
+ </div>
57
+
58
  <div>
59
  <label for="username">Username:</label>
60
  <input type="text" id="username" placeholder="Enter your username">
 
65
  if (!window.SpeechRecognition) {
66
  alert("Your browser does not support Speech Recognition. Try Google Chrome.");
67
  }
68
+ // ... existing code ...
69
+
70
  let recognition = new window.SpeechRecognition();
71
  recognition.continuous = true;
72
  recognition.interimResults = true;
73
  let liveOutput = document.getElementById('transcription');
74
  let lastTranscription = '';
75
+
76
+ // Function to update language
77
+ function updateLanguage() {
78
+ let selectedLanguage = document.getElementById('language').value;
79
+ recognition.lang = selectedLanguage;
80
+ }
81
+
82
+ // Set initial language
83
+ updateLanguage();
84
+
85
+ // Update language when user changes selection
86
+ document.getElementById('language').addEventListener('change', updateLanguage);
87
+
88
+ // ... rest of your existing code ...
89
+
90
 
91
  recognition.onresult = (event) => {
92
  let currentTranscription = '';