Text-to-voice E2 using if & sound play commands.

So a very simple but good enough E2 text-to-voice script would be using the if command line but I don’t know how to connect that to soundplay.



@name Talk
runOnTick(1)

if(owner():lastSaid() == "example" soundPlay (0,0, "synth/tri.wav")


Basically what I would like is a fixed example of the above line. Something that allows me in the chat to say, for example; ‘‘Hello’’ and have a .wav file played.
Anybody here capable of that?

Seems like you don’t know E2 at all, but try this


@persist Sounds:table

runOnChat(1)

if (first()) {
    Sounds["hello", string] = "aaaaaaahhh.mp3"
    Sounds["bye", string] = "myauhh.mp3"
    Sounds["aww", string] = "bot/aww_man.wav"
}

if (chatClk(owner())) {
    Sound = Sounds[owner():lastSaid():lower(), string]
    if (Sound) {
        owner():soundPlay("tts", 1, Sound)
    }
}


You can also do google tts with soundPlayURL. I recommend you to learn EA2, not E2.

More like I don’t know what I am looking for. This code is nice but a few years ago I made a e2 that was simply a one line going roughly as the example I made. It was structured like: If someone says a Word the E2 would play a sound.
By any chance know what I mean?

[editline]16th February 2017[/editline]

I Think I broke this thread but: More like I don’t know what I am lookng for. A few years ago I made a E2 that would, when seeing a Word or phrase in the chat, play a sound. It was a simple one line, no strings. A simply, ish; if said ‘‘blabal’’ soundplay ‘‘example.wav’’. Not exactly like that but similar.
Any chance you know what I mean?


runOnChat(1)
if (lastSaid() == "aah") {
    soundPlay("tts", 1, "bot/aah.wav")
}
elseif (lastSaid() == "asd") { # how you can stack them
    soundPlay("tts", 1, "")
}

Like this? With runOnTick it will spam, so use runOnChat instead.

UPD: You can’t do it in one line

[QUOTE= .[/QUOTE]

Yes, that is much more like what I remember. Not exactly but similar. The E2 I made had many problems but was alike a single line. 3 years is a lot of time so who knows. Maybe I’ll find a way to remake the original using this as a basis.
And I have no idea what happened to this thread, last time I posted I quoted you and that quote with the code background is a very long comment that makes it impossible for me to see any future comments (using translate to see what you typed). But I guess this solves it, so if you or anyone else says anything chances are I won’t know since the thread is broken for me but thanks anyways.