Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Pédagogies Multimodales
Phonographe
Commits
7da757d9
Commit
7da757d9
authored
Mar 01, 2021
by
Sylvain Coulange
Browse files
ajout fonction débit parole pour synthèse vocale
parent
c16ce8c2
Changes
5
Hide whitespace changes
Inline
Side-by-side
clavier/text2speech.py
View file @
7da757d9
...
...
@@ -8,7 +8,7 @@ from contextlib import closing
# Liste des phonèmes acceptés pour le français : https://docs.aws.amazon.com/polly/latest/dg/ph-table-french.html
# Liste des tags ssml disponibles : https://docs.aws.amazon.com/polly/latest/dg/supportedtags.html#s-tag
def
lambda_handler
(
ipa
,
loc
):
def
lambda_handler
(
ipa
,
debit
,
loc
):
# init polly
polly
=
boto3
.
client
(
"polly"
)
...
...
@@ -22,7 +22,7 @@ def lambda_handler(ipa, loc):
# generate phoneme tag for polly to read
text
=
text
.
replace
(
' '
,
"'></phoneme><break/><phoneme alphabet='ipa' ph='"
)
phoneme
=
"<prosody rate='
85
%'><phoneme alphabet='ipa' ph='"
+
text
+
"'></phoneme></prosody>"
#<prosody rate='85%'></prosody>
phoneme
=
"<prosody rate='
"
+
debit
+
"
%'><phoneme alphabet='ipa' ph='"
+
text
+
"'></phoneme></prosody>"
#<prosody rate='85%'></prosody>
# send to polly, requesting mp3 back
response
=
polly
.
synthesize_speech
(
...
...
clavier/views.py
View file @
7da757d9
...
...
@@ -132,9 +132,11 @@ def openPlayerPhono(request, pk):
def
playIpa
(
request
):
colis
=
json
.
loads
(
request
.
body
)
ipa
=
colis
[
'ipa'
]
print
(
"Lecture de ["
+
ipa
+
"]"
)
# debit = colis['debit']
debit
=
"100"
print
(
"Lecture de ["
+
ipa
+
"] débit "
+
debit
)
audioBytes
,
lenssml
=
lambda_handler
(
ipa
,
"Celine"
)
audioBytes
,
lenssml
=
lambda_handler
(
ipa
,
debit
,
"Celine"
)
data
=
{
"audio"
:
audioBytes
...
...
static/js/clavier.js
View file @
7da757d9
...
...
@@ -583,6 +583,7 @@ function openInNewTab() {
}
var
currentIpa
=
""
;
var
currentDebit
=
80
;
async
function
playIpa
()
{
if
(
thisPageLang
==
'
fr
'
){
// Si quelque chose est écrit...
...
...
@@ -604,13 +605,13 @@ async function playIpa() {
}
ipa
=
ipa
.
trim
();
// suppression des espaces en début ou en fin
if
(
ipa
!=
currentIpa
){
console
.
log
(
"
lecture de
"
,
ipa
);
currentIpa
=
ipa
;
// ON EMBALLE TOUT ÇA
var
colis
=
{
'
ipa
'
:
ipa
,
ipa
,
'
appli
'
:
'
phonographe
'
};
...
...
@@ -629,7 +630,9 @@ async function playIpa() {
const
data
=
await
response
.
json
();
readResponse
(
data
[
"
audio
"
]);
}
else
{
document
.
getElementsByTagName
(
"
audio
"
)[
0
].
play
();
var
audio
=
document
.
getElementsByTagName
(
"
audio
"
)[
0
];
audio
.
playbackRate
=
document
.
getElementById
(
'
debitParole
'
).
value
/
100
;
audio
.
play
();
}
}
}
else
window
.
alert
(
"
Cette fonctionnalité n'est pas encore disponible pour l'anglais !
"
);
...
...
@@ -638,6 +641,7 @@ async function playIpa() {
function
readResponse
(
response
)
{
var
source
=
'
<source src="data:audio/mpeg;base64,
'
+
response
+
'
" type="audio/mpeg"></source>
'
;
var
audio
=
'
<audio autoplay="true" controls>
'
+
source
+
'
</audio>
'
;
audio
.
playbackRate
=
document
.
getElementById
(
'
debitParole
'
).
value
/
100
;
document
.
getElementById
(
'
audio
'
).
innerHTML
=
audio
;
}
...
...
static/styles/clavier.css
View file @
7da757d9
...
...
@@ -400,6 +400,31 @@ footer {
border
:
2px
solid
black
;
}
.btn-lecture
{
font-size
:
1rem
;
text-align
:
center
;
}
.btn-lecture
input
{
font-style
:
italic
;
color
:
rgb
(
190
,
190
,
190
);
background-color
:
black
;
border
:
0px
;
width
:
40px
;
-moz-appearance
:
textfield
;
text-align
:
center
;
}
.btn-lecture
input
::-webkit-inner-spin-button
{
-webkit-appearance
:
none
;
margin
:
0
;
}
.btn-lecture
input
:focus
{
-moz-appearance
:
initial
;
}
.btn-lecture
input
:focus::-webkit-inner-spin-button
{
-webkit-appearance
:
initial
;
margin
:
0
;
}
/* RESPONSIVE CSS */
@media
only
screen
and
(
max-width
:
700px
)
{
...
...
templates/clavier.html
View file @
7da757d9
...
...
@@ -29,11 +29,16 @@
<div
class=
"d-flex justify-content-between fenetre textSide textZone"
id=
"textZoneBack"
>
<div
id=
"textZone"
contenteditable=
"false"
spellcheck=
"true"
></div>
<div
class=
"pe-3"
onclick=
"playIpa();"
style=
"cursor: pointer;"
title=
"Prononcer !"
>
<svg
xmlns=
"http://www.w3.org/2000/svg"
width=
"40"
height=
"40"
fill=
"currentColor"
class=
"bi bi-play-circle nobg"
viewBox=
"0 0 16 16"
>
<path
d=
"M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"
/>
<path
d=
"M6.271 5.055a.5.5 0 0 1 .52.038l3.5 2.5a.5.5 0 0 1 0 .814l-3.5 2.5A.5.5 0 0 1 6 10.5v-5a.5.5 0 0 1 .271-.445z"
/>
</svg>
<div
class=
"my-auto btn-lecture d-flex flex-column align-items-stretch pe-3"
>
<div
onclick=
"playIpa();"
style=
"cursor: pointer;"
title=
"Prononcer !"
>
<svg
xmlns=
"http://www.w3.org/2000/svg"
width=
"40"
height=
"40"
fill=
"currentColor"
class=
"bi bi-play-circle nobg"
viewBox=
"0 0 16 16"
>
<path
d=
"M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"
/>
<path
d=
"M6.271 5.055a.5.5 0 0 1 .52.038l3.5 2.5a.5.5 0 0 1 0 .814l-3.5 2.5A.5.5 0 0 1 6 10.5v-5a.5.5 0 0 1 .271-.445z"
/>
</svg>
</div>
<input
type=
"number"
value=
"80"
id=
"debitParole"
title=
"Débit de parole"
min=
"0"
max=
"150"
step=
"10"
>
</div>
</div>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment