Welcome,
Guest
. Please
login
or
register
.
Username :
Password :
16 05, 2024, 08:07:24 pm
News:
Home
Forum
Rules
Help
Login
Register
CIT Forum Index
»
Ingame Community
»
News and Updates
»
[Danzy] Adding Text-to-Speech Feature for /highlights
« previous
next »
Print
Pages: [
1
]
Author
Topic: [Danzy] Adding Text-to-Speech Feature for /highlights (Read 1627 times)
Egekan
eggplant
Outstanding Community Member
Posts: 1479
Registered: 31/08/2011
Group: SAPD
Ingame: Egekan
[Danzy] Adding Text-to-Speech Feature for /highlights
«
on:
04 06, 2021, 03:53:42 am »
Hello,
Sometimes when you are busy, something triggers one of your /highlights entries. Unfortunately, it is not possible to change the sound for different highlights. So the only way to know which one was it to go back to the game and find the chat output in question. Instead of adding different sound options it is possible to make Google read them for you!
This suggestion is about making /highlights GUI read notifications using Google's Text-to-Speech instead of playing the same sound for every single notification. This is the GUI that appears when you use /highlights command:
Another
checkbox
can be placed under sound option which says "Use Google Text-to-Speech" to enable/disable this TTS feature.
Also adding an
edit box
or maybe a
combobox
that has language options in it below that checkbox sounds cool. So it will be possible to make it read them in different languages, this will help a lot if you are unable to speak English but still want to use that feature in your language.
Function you need to use in order to implement this feature to MTA:
Client:
Code: Lua
addEvent
(
"playTTS"
,
true
)
-- Add the event
local
function
playTTS
(
text
,
lang
)
--local URL = "http://translate.google.com/translate_tts?tl=" .. lang .. "&q=" .. text
--local URL = "https://code.responsivevoice.org/getvoice.php?tl=" .. lang .. "&t=" .. text
local
URL
=
"http://translate.google.com/translate_tts?tl="
..
lang
..
"&q="
..
text
..
"&client=tw-ob"
-- Play the TTS. BASS returns the sound element even if it can not be played.
return
true
,
playSound
(
URL
)
,
URL
end
addEventHandler
(
"playTTS"
,
root
,
playTTS
)
Shared:
Code: Lua
function
convertTextToSpeech
(
text
,
broadcastTo
,
lang
)
-- Ensure first argument is valid
assert
(
type
(
text
)
==
"string"
,
"Bad argument 1 @ convertTextToSpeech [ string expected, got "
..
type
(
text
)
..
"]"
)
assert
(
#
text
<=
100
,
"Bad argument 1 @ convertTextToSpeech [ too long string; 100 characters maximum ]"
)
if
triggerClientEvent
then
-- Is this function called serverside?
-- Ensure second and third arguments are valid
assert
(
broadcastTo
==
nil
or
type
(
broadcastTo
)
==
"table"
or
isElement
(
broadcastTo
)
,
"Bad argument 2 @ convertTextToSpeech [ table/element expected, got "
..
type
(
broadcastTo
)
..
"]"
)
assert
(
lang
==
nil
or
type
(
lang
)
==
"string"
,
"Bad argument 3 @ convertTextToSpeech [ string expected, got "
..
type
(
lang
)
..
"]"
)
-- Tell the client to play the speech
return
triggerClientEvent
(
broadcastTo
or
root
,
"playTTS"
,
root
,
text
,
lang
or
"en"
)
else
-- This function is executed clientside
local
lang
=
broadcastTo
-- Ensure second argument is valid
assert
(
lang
==
nil
or
type
(
lang
)
==
"string"
,
"Bad argument 2 @ convertTextToSpeech [ string expected, got "
..
type
(
lang
)
..
"]"
)
return
playTTS
(
text
,
lang
or
"en"
)
end
end
Please refer to
this MTA wiki page
for details of the function. Everything is explained well there.
List of languages supported by Google Text-to-Speech and their codes:
Click Here
An example to give you an idea about how it works:
http://translate.google.com/translate_tts?tl=en-GB&q=Thissuggestionisamazing&client=tw-ob
«
Last Edit: 05 06, 2021, 06:01:34 pm by Arran
»
Logged
Senza
Mr. Catface
Honorable
Posts: 3324
A cat
Registered: 13/01/2016
Re: Adding Text-to-Speech Feature for /highlights
«
Reply #1 on:
04 06, 2021, 03:57:59 am »
Such a cool suggestion and also easy to implement, always wondered what we can use TTS for, but this is definitely a good start. Positive.
Logged
Arran
Administrator
Posts: 5653
Registered: 20/11/2010
Ingame: [CIT]Arran
Re: Adding Text-to-Speech Feature for /highlights
«
Reply #2 on:
05 06, 2021, 05:58:41 pm »
@Danzy
since this is in your repo you can add it.
Logged
Proof You Are so Much More Than What You Realise
Authority is not truth. Truth is authority.
Danzy
The Amplifier
L4 Staff
Posts: 2499
infernoob
Registered: 21/05/2011
Re: [Danzy] Adding Text-to-Speech Feature for /highlights
«
Reply #3 on:
06 06, 2021, 01:33:22 pm »
Work in progress.
Logged
We don't search for old songs, we search for old memories.
Arran
Administrator
Posts: 5653
Registered: 20/11/2010
Ingame: [CIT]Arran
Re: [Danzy] Adding Text-to-Speech Feature for /highlights
«
Reply #4 on:
30 06, 2021, 04:52:48 pm »
@Danzy
any progress?
Logged
Proof You Are so Much More Than What You Realise
Authority is not truth. Truth is authority.
Danzy
The Amplifier
L4 Staff
Posts: 2499
infernoob
Registered: 21/05/2011
Re: [Danzy] Adding Text-to-Speech Feature for /highlights
«
Reply #5 on:
30 06, 2021, 05:16:00 pm »
Uh yes it should be done, might need some testing on com dev though.
Logged
We don't search for old songs, we search for old memories.
Vampire
vompire
Non Administrative Staff
Posts: 3299
The Undeadly Thirst
Registered: 17/04/2015
Ingame: [CIT]Vampire
Re: [Danzy] Adding Text-to-Speech Feature for /highlights
«
Reply #6 on:
03 07, 2021, 02:13:41 pm »
Quote from: Danzy on 30 06, 2021, 05:16:00 pm
Uh yes it should be done, might need some testing on com dev though.
Tested it and it seems to be working just fine.
Logged
"Being reminded for something you worked really hard is good to your soul, and see that you left your mark behind is good to your mind" - Vampire 2017
Arran
Administrator
Posts: 5653
Registered: 20/11/2010
Ingame: [CIT]Arran
Re: [Danzy] Adding Text-to-Speech Feature for /highlights
«
Reply #7 on:
03 07, 2021, 07:25:22 pm »
If I'm to add this I need details / a submission topic.
Logged
Proof You Are so Much More Than What You Realise
Authority is not truth. Truth is authority.
Vampire
vompire
Non Administrative Staff
Posts: 3299
The Undeadly Thirst
Registered: 17/04/2015
Ingame: [CIT]Vampire
Re: [Danzy] Adding Text-to-Speech Feature for /highlights
«
Reply #8 on:
13 07, 2021, 04:26:25 am »
- Added text to speech support to /highlights. If you already have existing highlights, you can select them, select a language and click 'Save' to enable text to speech support with a set language. (Danzy + Egekan)
Logged
"Being reminded for something you worked really hard is good to your soul, and see that you left your mark behind is good to your mind" - Vampire 2017
Print
Pages: [
1
]
« previous
next »
CIT Forum Index
»
Ingame Community
»
News and Updates
»
[Danzy] Adding Text-to-Speech Feature for /highlights