Skip to content

Commit

Permalink
speechrecognation
Browse files Browse the repository at this point in the history
  • Loading branch information
yasinfmd committed May 6, 2024
1 parent 7f8d8fa commit 0576ab9
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 0 deletions.
19 changes: 19 additions & 0 deletions speechrecognation/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<button id="btn">Dinle</button>
<div class="s s1">Section 1</div>
<div class="s s2">Section 1</div>
<div class="s s3">Section 1</div>
<div class="s s4">Section 1</div>
<div class="s s5">Section 1</div>

<script type="module" src="/main.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions speechrecognation/javascript.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions speechrecognation/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import './style.css'
const btn=document.getElementById('btn')
const scrollToEl=(el)=>{
document.querySelector(el).scrollIntoView({
behavior:'smooth'
})

}

const handleMic=()=>{
if(window.SpeechRecognition || window.webkitSpeechRecognition){
const recognition=new window.webkitSpeechRecognition || window.webkitSpeechRecognition()
let isListening=false
const startRecognition=()=>{
recognition.start()
isListening=true
btn.innerHTML="Dinleniyor"
}
const stopRecoginition=()=>{
recognition.stop()
isListening=false
btn.innerHTML="Dinle"
}
btn.onclick=()=>{
if(isListening===false){
startRecognition()
}else{
stopRecoginition()
}
recognition.onerror=(e)=>
{

}
recognition.onresult=(e)=>{
const command=e.results[e.results.length-1][0]
if(command.confidence>0.5){
if(command.transcript.toLowerCase().includes('s1 git')){
stopRecoginition()
scrollToEl('.s1')
}
if(command.transcript.toLowerCase().includes('s2 git')){
stopRecoginition()
scrollToEl('.s2')

}
if(command.transcript.toLowerCase().includes('s5 git')){
stopRecoginition()
scrollToEl('.s3')
}
if(command.transcript.toLowerCase().includes('durdur')){
stopRecoginition()
}
}
}
}

}
}
handleMic()
14 changes: 14 additions & 0 deletions speechrecognation/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "speechapp",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"devDependencies": {
"vite": "^5.2.0"
}
}
1 change: 1 addition & 0 deletions speechrecognation/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
122 changes: 122 additions & 0 deletions speechrecognation/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}

body {
margin: 0;
display: flex;
flex-direction: column;

}

h1 {
font-size: 3.2em;
line-height: 1.1;
}

#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.vanilla:hover {
filter: drop-shadow(0 0 2em #f7df1eaa);
}

.card {
padding: 2em;
}

.read-the-docs {
color: #888;
}

button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}

@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}


.s{
height: 100vh;
}
.s1{
background-color: #535bf2;
}

.s2{
background-color: #747bff;
}

.s3{
background-color: aqua;
}
.s4{
background-color:cyan;
}
.s5{
background-color: teal;
}
#btn{
position: fixed;
bottom: 0;
right: 16px;
}

0 comments on commit 0576ab9

Please sign in to comment.