Author Topic: Dictation until silence  (Read 16850 times)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4800
  • RTFM
Dictation until silence
« on: June 23, 2019, 04:50:42 PM »
Code: [Select]
Start Dictation Mode (Clearing Dictation Buffer)
Set date [~speechTimeout] to [~speechTimeout] plus [5] seconds
Start Indefinite Loop
    Begin Text Compare : [{STATE_SPEECHACTIVE}] Equals '0'
        Begin Date Compare : [~speechTimeout] Is Before Current Date/Time
            Stop Dictation Mode
            Write [Blue] '{DICTATION}' to log
        End Condition - Exit when condition met
    Else
        Set date [~speechTimeout] value to the current date/time
        Set date [~speechTimeout] to [~speechTimeout] plus [3] seconds
    End Condition
End Loop

With these parameters, you have 8 seconds to start speaking (5 initial, plus the 3 from the timeout), and 3 seconds after the speech recognition engine last detects speech it'll stop the dictation and write what you said to the log.
« Last Edit: April 15, 2020, 08:57:07 AM by Pfeil »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4800
  • RTFM
Re: Dictation until silence
« Reply #1 on: August 24, 2022, 03:14:35 PM »
A basic example for simpler, one-shot dictation (I.E. you execute the command, and as soon as the speech recognition system recognizes something, what was recognized is written to the log on the main window, and the command completes):
Code: [Select]
Start Dictation Mode (Clearing Dictation Buffer)
Start Loop While : [{DICTATION}] Equals ''
End Loop
Stop Dictation Mode
Write [Blue] '{DICTATION}' to log

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4800
  • RTFM
Re: Dictation until silence
« Reply #2 on: July 23, 2023, 04:14:45 PM »
VoiceAttack v1.10.4 or newer can utilize the "Wait For Spoken Response" action to retrieve arbitrary spoken text, without needing to use the dictation mode, or an explicit loop:
Code: [Select]
Wait for any spoken response
Write [Blue] '{TXT:~textResult}' to log


The "Responses" field is to be left blank.

If the "Timeout" value is not set to 0 or less, or left blank, after the entered value (the default being 15 seconds) has elapsed, "Not set" would be written to the log.

As the dictation buffer is specific to the dictation mode, it is not utilized here. Instead, a normal text variable will be set, and its value can be retrieved using the "{TXT:}" token, as shown.

In versions older than beta v1.10.6.14, the "Text Variable" field needs to be manually populated with the value "~textResult" (or another variable name; it just needs to match what you're using elsewhere, E.G. in the "Write a Value to the Event Log" action).