Commit
·
0e1d7d8
1
Parent(s):
6ca7a13
Added New HTML
Browse filesAdded Flask Code
- main.py +19 -5
- templates/index.html +81 -0
main.py
CHANGED
|
@@ -1,7 +1,21 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
| 2 |
|
| 3 |
-
app = FastAPI()
|
| 4 |
|
| 5 |
-
@app.get("/")
|
| 6 |
-
def read_root():
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# from fastapi import FastAPI
|
| 2 |
|
| 3 |
+
# app = FastAPI()
|
| 4 |
|
| 5 |
+
# @app.get("/")
|
| 6 |
+
# def read_root():
|
| 7 |
+
# return
|
| 8 |
+
|
| 9 |
+
from flask import Flask, render_template
|
| 10 |
+
from flask_compress import Compress
|
| 11 |
+
import socket
|
| 12 |
+
|
| 13 |
+
host_name = socket.gethostname()
|
| 14 |
+
host_name_ipaddress = socket.gethostbyname(host_name)
|
| 15 |
+
|
| 16 |
+
app = Flask(__name__)
|
| 17 |
+
Compress(app)
|
| 18 |
+
|
| 19 |
+
@app.route('/')
|
| 20 |
+
def get_all_posts():
|
| 21 |
+
return render_template("index.html")
|
templates/index.html
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Speech Recognition Example</title>
|
| 7 |
+
<style>
|
| 8 |
+
body {
|
| 9 |
+
font-family: Arial, sans-serif;
|
| 10 |
+
text-align: center;
|
| 11 |
+
margin-top: 50px;
|
| 12 |
+
}
|
| 13 |
+
button {
|
| 14 |
+
padding: 10px 20px;
|
| 15 |
+
font-size: 16px;
|
| 16 |
+
cursor: pointer;
|
| 17 |
+
background-color: #4CAF50;
|
| 18 |
+
color: white;
|
| 19 |
+
border: none;
|
| 20 |
+
border-radius: 5px;
|
| 21 |
+
}
|
| 22 |
+
#transcription {
|
| 23 |
+
margin-top: 20px;
|
| 24 |
+
font-size: 18px;
|
| 25 |
+
color: #333;
|
| 26 |
+
}
|
| 27 |
+
</style>
|
| 28 |
+
</head>
|
| 29 |
+
<body>
|
| 30 |
+
|
| 31 |
+
<h1>Speech Recognition</h1>
|
| 32 |
+
<button onclick="startSpeech()">Start Speech</button>
|
| 33 |
+
|
| 34 |
+
<div id="transcription"></div>
|
| 35 |
+
|
| 36 |
+
<script>
|
| 37 |
+
function startSpeech() {
|
| 38 |
+
// Check if SpeechRecognition is available in the browser
|
| 39 |
+
var SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
|
| 40 |
+
|
| 41 |
+
if (!SpeechRecognition) {
|
| 42 |
+
alert("Speech recognition is not supported in this browser.");
|
| 43 |
+
return;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
// Create a new instance of SpeechRecognition
|
| 47 |
+
var recognition = new SpeechRecognition();
|
| 48 |
+
|
| 49 |
+
// Set recognition to listen continuously
|
| 50 |
+
recognition.continuous = true;
|
| 51 |
+
recognition.interimResults = true;
|
| 52 |
+
|
| 53 |
+
// Start listening for speech
|
| 54 |
+
recognition.start();
|
| 55 |
+
|
| 56 |
+
recognition.onstart = function() {
|
| 57 |
+
document.getElementById("transcription").textContent = "Listening... Speak now!";
|
| 58 |
+
};
|
| 59 |
+
|
| 60 |
+
recognition.onspeechend = function() {
|
| 61 |
+
recognition.stop();
|
| 62 |
+
document.getElementById("transcription").textContent = "Speech recognition ended.";
|
| 63 |
+
};
|
| 64 |
+
|
| 65 |
+
recognition.onerror = function(event) {
|
| 66 |
+
document.getElementById("transcription").textContent = "Error occurred: " + event.error;
|
| 67 |
+
};
|
| 68 |
+
|
| 69 |
+
recognition.onresult = function(event) {
|
| 70 |
+
var transcript = "";
|
| 71 |
+
for (var i = event.resultIndex; i < event.results.length; i++) {
|
| 72 |
+
transcript += event.results[i][0].transcript;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
document.getElementById("transcription").textContent = transcript;
|
| 76 |
+
};
|
| 77 |
+
}
|
| 78 |
+
</script>
|
| 79 |
+
|
| 80 |
+
</body>
|
| 81 |
+
</html>
|