Author Topic: Randomize TTS comments  (Read 81 times)

Danks

  • Newbie
  • *
  • Posts: 3
Randomize TTS comments
« on: September 09, 2018, 01:53:56 pm »
Hello VA users, first post here, hope this is the right place for this question.

I am putting together a list of TTS quotes, sayings, and one-liner jokes. They are just simple TTS 'Say' entries, all contained within a single command . I would like to randomize this list. The only way I can find to randomize anything is to set a random integer variable; it's max number being how many total sayings there are, then set jump markers for each individual quote, which reference the chosen random number. I have each entry set to exit command once it's done playing.

Obviously, one can see this list can get extremely overwhelming. Am I going about this correctly? I am absolutely new to any sort of programming, and my understanding is there are multiple ways to do things, some more efficient (correct?) than others.

Also, is there a limit as to how extensive a particular command can go? How far can I go before it breaks\explodes\goes singularity?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1570
  • RTFM
Re: Randomize TTS comments
« Reply #1 on: September 09, 2018, 02:08:39 pm »
VoiceAttack can do this for you natively:

Put your lines into a single TTS action, wrapped in curly braces, and separated by semicolons, and VoiceAttack will pick one of them at random each time the action runs.

E.G.
Code: [Select]
{say this;or this;or even this}
If you have many variations, note that you can also structure it like this to make it easier to manage:
Code: [Select]
{
say this;
or this;
or even this
}


For more information check VoiceAttackHelp.pdf(press F1 to open it while VoiceAttack has focus) page 37 and 38.


Also, is there a limit as to how extensive a particular command can go? How far can I go before it breaks\explodes\goes singularity?
There are few "hard" limits in VoiceAttack, so it mainly depends on your particular system.

VoiceAttack keeps backups of your profile database, so if you do make a change that causes issues it should be possible to recover from.

Danks

  • Newbie
  • *
  • Posts: 3
Re: Randomize TTS comments
« Reply #2 on: September 09, 2018, 02:26:55 pm »
That worked perfectly. Thank you!

On a side note, I'm also trying to work on a typical joke exchange. e.g. knock knock, who's there

I have come up with a crude way of doing it from what it looks like. How would you all set this up?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1570
  • RTFM
Re: Randomize TTS comments
« Reply #3 on: September 09, 2018, 04:02:40 pm »
I'd have set it up like this:
Code: [Select]
Inline C# Function: Get joke text, wait until execution finishes
Say, 'Knock knock'
Wait for spoken response: 'who's there'
Begin Text Compare : [~response] Does Not Contain 'who’s there'
    Say, 'Aah, you're no fun.'
End Condition - Exit when condition met
Say, '{TXT:~jokeStart}.'
Wait for spoken response: '{TXT:~jokeStart} who'
Begin Text Compare : [~response] Does Not Contain '{TXT:~jokeStart} who'
    Say, 'Aah, you're no fun.'
End Condition - Exit when condition met
Say, '{TXT:~jokeEnd}.'

Where "Get joke text" contains
Code: [Select]
using System;

public class VAInline
{
public void main()
{
string[] jokes =
{
"Cash", "No thanks, I’ll have some peanuts",
"Boo", "No need to cry, it’s only a joke",
"To", "It's to whom"
};

Random rand = new Random();
int r = (2 * rand.Next(0 / 2, jokes.Length / 2));

VA.SetText("~jokeStart", jokes[r]);
VA.SetText("~jokeEnd", jokes[r + 1]);
}
}

However, in the process of setting that up, I found out "Wait For Spoken Response" doesn't accept tokens, and getting dictation(the way of recognizing arbitrary text used before "Wait For Spoken Response" was a thing) to recognize a phrase consisting of a single word follow by "who" would just be an exercise in frustration.

I've put in a feature request to potentially make this possible.


EDIT: "Contains" should be "Does Not Contain", oddly enough that always returned false(which I why I had it like that, to test) until I rebuilt the command, strange bug that.
« Last Edit: September 19, 2018, 05:26:56 am by Pfeil »

Danks

  • Newbie
  • *
  • Posts: 3
Re: Randomize TTS comments
« Reply #4 on: September 09, 2018, 10:00:18 pm »
Yeah, that all looks way past my abilities at this point. So far I've gotten by with something like this:

Code: [Select]
Marker: chicken_road_mk
Say, 'Why did the chicken cross the road?'  (and wait until it completes)
Wait for spoken response: 'no;why'
Begin Text Compare : [chicken_why] Equals 'why'
    Say, '{ Chickens are incapable of cognitive reasoning, therefore it was random,' or ' Because it was the turkey's day off.' or ' I don't know what the chicken did, but the road sure was pissed off.' or ' Because Church's Chicken is not a religious gathering.' or ' }'  (and wait until it completes)
Else If Text Compare : [chicken_why] Equals 'no'
    Say, '{ We've heard them all, haven't we' or ' Okay, never mind [,what ever' or '].' or ' }'  (and wait until it completes)
Else If Text Compare : [chicken_why] Has Not Been Set
    Say, '{ Hello? Wow, that was rude.' or ' Seeing as I have no audience, never mind. }'  (and wait until it completes)
Else If Text Compare : [chicken_why] Equals '@@invalid'
    Say, '{ Sorry, I didn't catch that. }'  (and wait until it completes)
    Jump to Marker: chicken_road_mk
End Condition - Exit when condition met or not met

How is that for a beginner?