Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PAnTHer
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
puma
client
PAnTHer
Commits
86adff9f
Commit
86adff9f
authored
9 months ago
by
Lucio Zambon
Browse files
Options
Downloads
Patches
Plain Diff
Update talk.php
parent
a5b5239c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
speech/talk.php
+32
-35
32 additions, 35 deletions
speech/talk.php
with
32 additions
and
35 deletions
speech/talk.php
+
32
−
35
View file @
86adff9f
<?php
<?php
$local
=
isset
(
$_REQUEST
[
'cdn'
])
?
false
:
true
;
// true = use only locally installed modules, false = use cdn
$hs
=
[
'192.168.231.21'
=>
'do'
,
'192.168.231.22'
=>
're'
,
'192.168.231.23'
=>
'mi'
,
'192.168.231.24'
=>
'fa'
,
'192.168.231.25'
=>
'sol'
,
'192.168.231.26'
=>
'la'
,
'192.168.231.27'
=>
'si'
];
$hs
=
[
'192.168.231.21'
=>
'do'
,
'192.168.231.22'
=>
're'
,
'192.168.231.23'
=>
'mi'
,
'192.168.231.24'
=>
'fa'
,
'192.168.231.25'
=>
'sol'
,
'192.168.231.26'
=>
'la'
,
'192.168.231.27'
=>
'si'
];
$lang
=
empty
(
$_REQUEST
[
'lang'
])
?
'
en
'
:
substr
(
$_REQUEST
[
'lang'
],
0
,
2
);
$lang
=
empty
(
$_REQUEST
[
'lang'
])
?
'
it
'
:
substr
(
$_REQUEST
[
'lang'
],
0
,
2
);
$host
=
isset
(
$hs
[
$_SERVER
[
'REMOTE_ADDR'
]])
?
$hs
[
$_SERVER
[
'REMOTE_ADDR'
]]
:
$_SERVER
[
'REMOTE_ADDR'
];
$host
=
isset
(
$hs
[
$_SERVER
[
'REMOTE_ADDR'
]])
?
$hs
[
$_SERVER
[
'REMOTE_ADDR'
]]
:
$_SERVER
[
'REMOTE_ADDR'
];
if
(
!
empty
(
$_REQUEST
[
'init'
]))
{
if
(
!
empty
(
$_REQUEST
[
'init'
]))
{
$t
=
$_REQUEST
[
'init'
]
-
0
;
$t
=
$_REQUEST
[
'init'
]
-
0
;
...
@@ -74,7 +75,17 @@
...
@@ -74,7 +75,17 @@
die
(
json_encode
(
$data
));
die
(
json_encode
(
$data
));
}
}
if
(
isset
(
$_REQUEST
[
'search'
]))
{
if
(
isset
(
$_REQUEST
[
'search'
]))
{
if
(
!
empty
(
$_REQUEST
[
'search'
]))
{
file_put_contents
(
"./msg"
,
$_REQUEST
[
'search'
]);
die
(
"
{
$_REQUEST
[
'search'
]
}
has been searched"
);}
require_once
(
"../../conf.php"
);
require_once
(
"../../lib/sql_interface.php"
);
$sql
=
open_db
();
$query
=
"SELECT speech, replace FROM speechreplace WHERE lang=$1"
;
$data
=
$sql
->
sql_secure
(
$query
,
array
(
$lang
));
$replace
=
[];
foreach
(
$data
as
$d
)
{
$replace
[
$d
[
'speech'
]]
=
$d
[
'replace'
];
}
$search
=
strtr
(
$_REQUEST
[
'search'
],
$replace
);
if
(
!
empty
(
$search
))
{
file_put_contents
(
"./msg"
,
$search
);
die
(
"
$search
has been searched"
);}
}
}
if
(
isset
(
$_REQUEST
[
'read'
]))
{
if
(
isset
(
$_REQUEST
[
'read'
]))
{
set_time_limit
(
0
);
set_time_limit
(
0
);
...
@@ -146,22 +157,24 @@
...
@@ -146,22 +157,24 @@
print_r
(
$xml
);
print_r
(
$xml
);
die
(
'</pre>'
);
die
(
'</pre>'
);
}
}
?>
?>
<!doctype html>
<!doctype html>
<html
lang=
"en"
>
<html
lang=
"en"
>
<head>
<head>
<meta
charset=
"utf-8"
>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<title>
CS Talk
</title>
<title>
CS Talk
</title>
<script
src=
"../../lib/jquery/jquery.min.js"
></script>
<link
rel=
"stylesheet"
href=
"
<?php
echo
(
$local
?
'../../lib/jquery/jquery-ui.min.css'
:
'https://code.jquery.com/ui/1.13.3/themes/base/jquery-ui.css'
);
?>
"
>
<link
rel=
"stylesheet"
href=
"https://puma-01.elettra.eu/lib/bootstrap4/bootstrap.min.css"
>
<script
src=
"
<?php
echo
(
$local
?
'../../lib/jquery/jquery.min.js'
:
'https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js'
);
?>
"
type=
"text/javascript"
></script>
<script
src=
"https://puma-01.elettra.eu/lib/bootstrap4/bootstrap.bundle.min.js"
></script>
<script
src=
"
<?php
echo
(
$local
?
'../../lib/jquery/jquery-ui.min.js'
:
'https://cdn.jsdelivr.net/npm/jquery-ui@1.13.3/dist/jquery-ui.min.js'
);
?>
"
type=
"text/javascript"
></script>
<link
rel=
"stylesheet"
href=
"../../lib/bootstrap4/bootstrap.min.css"
>
<script
src=
"../../lib/bootstrap4/bootstrap.bundle.min.js"
></script>
</head>
</head>
<body
onLoad=
'myload()'
>
<body
onLoad=
'myload()'
>
<div
id=
'transcriptDiv'
style=
'display:none;'
></div>
<div
style=
"max-width: 500px; text-align: center"
>
<div
style=
"max-width: 500px; text-align: center"
>
<audio
id=
'speechText'
onended=
'speakagain();'
onerror=
'showLog("audio err: "+event.error)'
></audio>
<audio
id=
'speechText'
onended=
'speakagain();'
onerror=
'showLog("audio err: "+event.error)'
></audio>
<table
id =
'openTable'
class=
"table table-hover"
></table>
<script>
<script>
window
.
openData
=
[];
window
.
openData
=
[];
const
t0
=
+
new
Date
();
const
t0
=
+
new
Date
();
...
@@ -239,6 +252,7 @@
...
@@ -239,6 +252,7 @@
<span
style=
'color: darkgreen; font-weight: bold;'
onClick=
'commandlistinfo()'
>
?
</span>
<span
style=
'color: darkgreen; font-weight: bold;'
onClick=
'commandlistinfo()'
>
?
</span>
</div>
</div>
<span
style=
'color: darkblue; font-weight: bold;'
id=
'miclabel'
>
comandi vocali
</span>
<span
style=
'color: darkblue; font-weight: bold;'
id=
'miclabel'
>
comandi vocali
</span>
<table
id =
'openTable'
class=
"table table-hover"
></table>
<pre
id=
'log'
></pre>
<pre
id=
'log'
></pre>
<script>
<script>
if
(
document
.
location
.
search
.
indexOf
(
'
debug
'
)
==-
1
)
$
(
'
#log
'
).
hide
();
if
(
document
.
location
.
search
.
indexOf
(
'
debug
'
)
==-
1
)
$
(
'
#log
'
).
hide
();
...
@@ -292,18 +306,21 @@
...
@@ -292,18 +306,21 @@
}
}
recognition.onend = function(event) {
recognition.onend = function(event) {
showLog(
'
.
'
);
showLog(
'
.
'
);
// document.getElementById(
'
miclabel
'
).style.display =
'
none
'
;
document.getElementById(
'
micna
'
).style.display =
'
none
'
;
document.getElementById(
'
micna
'
).style.display =
'
none
'
;
document.getElementById(
'
micstart
'
).style.display =
'
none
'
;
document.getElementById(
'
micstart
'
).style.display =
'
none
'
;
document.getElementById(
'
micstop
'
).style.display =
'
inline
'
;
document.getElementById(
'
micstop
'
).style.display =
'
inline
'
;
if (keepAlive && aliveTimer==-1) aliveTimer = setTimeout(startRec, 200);
if (keepAlive && aliveTimer==-1) aliveTimer = setTimeout(startRec, 200);
}
}
recognition.onstart = function(event) {
recognition.onstart = function(event) {
if (document.location.search.indexOf(
'
debug
'
)==-1) $(
'
#
log
'
).hide();
if (firstRun) {
if (firstRun) {
firstRun = false;
firstRun = false;
recognition.stop();
recognition.stop();
return;
return;
}
}
showLog(
'
-
'
);
showLog(
'
-
'
);
document.getElementById(
'
miclabel
'
).style.display =
'
none
'
;
document.getElementById(
'
micna
'
).style.display =
'
none
'
;
document.getElementById(
'
micna
'
).style.display =
'
none
'
;
document.getElementById(
'
micstart
'
).style.display =
'
inline
'
;
document.getElementById(
'
micstart
'
).style.display =
'
inline
'
;
document.getElementById(
'
micstop
'
).style.display =
'
none
'
;
document.getElementById(
'
micstop
'
).style.display =
'
none
'
;
...
@@ -338,8 +355,6 @@
...
@@ -338,8 +355,6 @@
for (let i=0; i<3; i++) {
for (let i=0; i<3; i++) {
$(
'
#
openTable
'
).html($(
'
#
openTable
'
).html()+
'
<
tr
><
td
>
'
+(i+1)+
'
<
/td><td>'+rlocale
[
i
]
.title+'</
td
><
td
>
'
+rlocale[i].description+
'
<
/td><td>'+rlocale
[
i
]
.exename+'</
td
><
/tr>'
)
;
$(
'
#
openTable
'
).html($(
'
#
openTable
'
).html()+
'
<
tr
><
td
>
'
+(i+1)+
'
<
/td><td>'+rlocale
[
i
]
.title+'</
td
><
td
>
'
+rlocale[i].description+
'
<
/td><td>'+rlocale
[
i
]
.exename+'</
td
><
/tr>'
)
;
window
.
openData
.
push
(
rlocale
[
i
]);
window
.
openData
.
push
(
rlocale
[
i
]);
// showLog(rlocale[i]);
// showLog(window.openData);
}
}
}
}
window
.
openData
.
push
(
txt
);
window
.
openData
.
push
(
txt
);
...
@@ -378,8 +393,14 @@
...
@@ -378,8 +393,14 @@
}
}
if
(
locale
[
lang
].
search
.
indexOf
(
tok
)
>-
1
)
{
if
(
locale
[
lang
].
search
.
indexOf
(
tok
)
>-
1
)
{
mode
=
'
search
'
;
mode
=
'
search
'
;
txt
=
txt
.
replace
(
tok
+
'
'
,
''
).
replace
(
'
ing
'
,
'
inj
'
).
replace
(
'
inch
'
,
'
inj
'
).
split
(
'
'
).
join
(
'
_
'
).
split
(
'
.
'
).
join
(
'
_
'
).
toUpperCase
();
names
=
[
'
pippo
'
,
'
pluto
'
,
'
goofy
'
,
'
scrooge
'
];
const
snd
=
'
./talk.php?search=
'
+
txt
+
'
&token=
'
+
document
.
location
.
search
.
split
(
'
?d=
'
)[
1
].
split
(
'
&
'
)[
0
];
// txt = txt.replace(tok+' ', '').replace('ing', 'inj').replace('inch', 'inj').split(' ').join('_').split('.').join('_').toUpperCase();
txt
=
txt
.
replace
(
tok
+
'
'
,
''
).
split
(
'
'
).
join
(
'
_
'
).
split
(
'
.
'
).
join
(
'
_
'
).
toUpperCase
();
const
token
=
document
.
location
.
search
.
indexOf
(
'
?d=
'
)
>-
1
?
'
&token=
'
+
document
.
location
.
search
.
split
(
'
?d=
'
)[
1
].
split
(
'
&
'
)[
0
];
const
snd
=
'
./talk.php?search=
'
+
txt
+
token
+
"
&lang=
"
+
lang
;
$
(
'
#openTable
'
).
html
(
'
<tr><td colspan="5">
'
+
locale
[
lang
].
searchCorrect
+
'
</td></tr>
'
);
$
(
'
#openTable
'
).
html
(
'
<tr><td>
'
+
txt
+
'
</td><td><input id="sname"></input></td><td><button onClick="alert(5)">
'
+
locale
[
lang
].
searchSubmit
+
'
</button></td></tr>
'
);
$
(
function
()
{
$
(
"
.sname
"
).
autocomplete
({
source
:
names
,
select
:
function
(
event
,
ui
)
{
findComponent
(
ui
.
item
.
value
);
return
false
;}});});
showLog
(
snd
);
showLog
(
snd
);
fetch
(
snd
).
then
((
response
)
=>
{
return
response
.
json
();}).
then
((
rlocale
)
=>
{
showLog
(
rlocale
);
alert
(
rlocale
);});
fetch
(
snd
).
then
((
response
)
=>
{
return
response
.
json
();}).
then
((
rlocale
)
=>
{
showLog
(
rlocale
);
alert
(
rlocale
);});
mode
=
''
;
mode
=
''
;
...
@@ -425,30 +446,6 @@
...
@@ -425,30 +446,6 @@
// document.getElementById('transcriptDiv').innerHTML = finalTranscript + '<i style=
\"
color:#00d;
\"
>' + interimTranscript + '</i>';
// document.getElementById('transcriptDiv').innerHTML = finalTranscript + '<i style=
\"
color:#00d;
\"
>' + interimTranscript + '</i>';
document.getElementById('transcriptDiv').innerHTML = '<i style=
\"
color:#00d;
\"
>' + finalTranscript + '</i>';
document.getElementById('transcriptDiv').innerHTML = '<i style=
\"
color:#00d;
\"
>' + finalTranscript + '</i>';
}
}
/*recognition.onresult = (event) => {
let interimTranscript = '';
for (let i = event.resultIndex, len = event.results.length; i < len; i++) {
let transcript = event.results[i][0].transcript;
const dt = new Time() - t0;
if (event.results[i][0].transcript.length) showLog(dt+' i: '+i+', transcripts: '+event.results[i][0].transcript+(event.results[i][1]? ', transcripts: '+event.results[i][1].transcript:'')+'
\n
');
if (event.results[i].isFinal) {
quick_add(transcript.toLowerCase());
var meno = transcript.toLowerCase().indexOf('meno ');
console.log(meno, transcript.substring(meno+5,meno+6), transcript.substring(meno+5,meno+6) % 1);
if (meno>-1 && transcript.substring(meno+5,meno+6) % 1 === 0) {
console.log('replace');
transcript = transcript.replace(transcript.substring(meno,meno+5), '-');
}
// finalTranscript += transcript+'<br>
\\
n';
if (transcript.length>0) finalTranscript = transcript;
} else {
interimTranscript += transcript+'<br>
\\
n';
}
document.getElementById('transcriptDiv').innerHTML = '<i style=
\"
color:#ddd;
\"
>' + interimTranscript + '</i>';
}
// document.getElementById('transcriptDiv').innerHTML = finalTranscript + '<i style=
\"
color:#00d;
\"
>' + interimTranscript + '</i>';
document.getElementById('transcriptDiv').innerHTML = '<i style=
\"
color:#00d;
\"
>' + finalTranscript + '</i>';
}*/
showLog('start'+'
\n
');
showLog('start'+'
\n
');
recognition.start();
recognition.start();
</script>
</script>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment