sveinbjornt / hear

Command line speech recognition and transcription for macOS
https://sveinbjorn.org/hear
BSD 3-Clause "New" or "Revised" License
303 stars 18 forks source link

Option to stop listening after a while #6

Closed synox closed 8 months ago

synox commented 1 year ago

I wish hear could stop automatically, instead of staying active. Maybe when there is no more input for 3 seconds, or when reaching a user-defined text length?

In my simple game, the user has to say back the word.

    say --voice="Samantha"  -- "$word [[slnc 400]]" 
    response=$(hear --mode)

    shopt -s nocasematch
    if [[  "${response}" == "${word}" ]]; then
        echo ✅ $word
    else
        echo 🛑 wrong. ➡  $word
        echo " - press enter for next word -"; read
    fi

However pressing CTRL-C to stop the listening it stops the script instead.

Also for scripting, the ESCAPE-DELETE control characters get into the way. A plain text output when the program is complete would be preffered. The --mode output looks like this


Good

Good morning

Workarounds:

sveinbjornt commented 1 year ago

It's a cool idea, I'll look into adding it.

sveinbjornt commented 1 year ago

I have added an exit word option, i.e. if you run "hear -x 'quit'", the transcription session will end as soon as you say the word 'quit'. That might help with your use case.

sveinbjornt commented 1 year ago

Btw, as for control characters, they are only emitted in single-line mode, which is intended for presentation in a terminal client. Omit the "--mode" flag if you don't want them.

synox commented 8 months ago

Thanks!