Author Topic: How do I split a phrase and insert audible 'beeps'...  (Read 894 times)

slicker55

  • Newbie
  • *
  • Posts: 17
How do I split a phrase and insert audible 'beeps'...
« on: November 25, 2018, 05:22:16 PM »
I am building a 'Check Channels' system for my flight sim...

I have used the 'When I say...' to deliver a 'Text To Speech' response and this works very well.

My code:

Check Channels [Anapa;Butumi;Sochi]


In the following example, I request channel information for the first of three airports (Anapa) and the response is read aloud from text entered by me in the 'Text To Speech' panel.

Example:

I say:

"Check Channels Anapa"

Response:

"Anapa, RSBN 2, PRMG 2, Tower 15"


Using the previous example, I would like it to split the phrase "Check Channels Anapa" into two sections "Check Channels" and "Anapa" and introduce an audible 'beep' when the words within each section have been understood correctly.

Example:

I say "Check Channels"

Response:

Audible 'beep'

I say:

"Anapa"

Response:

Audible 'beep'

"Anapa, RSBN 2, PRMG 2, Tower 15"





Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: How do I split a phrase and insert audible 'beeps'...
« Reply #1 on: November 25, 2018, 05:43:30 PM »
You can either use two separate commands, or the "Wait For Spoken Response" action.

The latter is arguably the simplest, as it will take care of the staging for you and keep all the logic in a single command for ease of maintenance:

Check Channels
Code: [Select]
Play sound, 'beep.mp3'
Wait for spoken response: 'Anapa;Butumi;Sochi'
Begin Text Compare : [~response] Has Not Been Set
End Condition - Exit when condition met
Play sound, 'beep.mp3'
Begin Text Compare : [~response] Equals 'Anapa'
    Say, 'Anapa, RSBN 2, PRMG 2, Tower 15'
Else If Text Compare : [~response] Equals 'Butumi'
    Say, 'Butumi, RSBN 2, PRMG 2, Tower 15'
Else If Text Compare : [~response] Equals 'Sochi'
    Say, 'Sochi, RSBN 2, PRMG 2, Tower 15'
End Condition


If you want one command to do both whole phrases and the separated sections, you could do something like this:
Check Channels [Anapa;Butumi;Sochi];Check Channels
Code: [Select]
Begin Text Compare : [{CMDSEGMENT:1}] Does Not Equal 'Not Set'
    Set Text [~response] to '{CMDSEGMENT:1}'
Else
    Play sound, 'beep.mp3'
    Wait for spoken response: 'Anapa;Butumi;Sochi'
    Begin Text Compare : [~response] Has Not Been Set
    End Condition - Exit when condition met
    Play sound, 'beep.mp3'
End Condition
Begin Text Compare : [~response] Equals 'Anapa'
    Say, 'Anapa, RSBN 2, PRMG 2, Tower 15'
Else If Text Compare : [~response] Equals 'Butumi'
    Say, 'Butumi, RSBN 2, PRMG 2, Tower 15'
Else If Text Compare : [~response] Equals 'Sochi'
    Say, 'Sochi, RSBN 2, PRMG 2, Tower 15'
End Condition


Both versions will stop the command if the "Wait For Spoken Response" action times out(because you haven't spoken valid input in the allotted time), so the command doesn't keep running in the background.

slicker55

  • Newbie
  • *
  • Posts: 17
Re: How do I split a phrase and insert audible 'beeps'...
« Reply #2 on: November 26, 2018, 09:22:50 AM »
Thank you for your swift advice ... (21 minutes will take some beating)...  :)

I decided to use the example you provided under the heading:

'If you want one command to do both whole phrases and the separated sections, you could do something like this:
Check Channels [Anapa;Butumi;Sochi];Check Channels'


Absolutely just what I wanted - soooo impressed!

Thank Beep You Beep So Beep Much!