Author Topic: Say {TXT:variable} but not same thing twice  (Read 3762 times)

PsiQss

  • Guest
Say {TXT:variable} but not same thing twice
« on: February 05, 2017, 01:59:33 AM »
Quick explanation: I have a text variable RESPONSES1 = [Response1; Response2; Response3; Response4 ...] and RESPONSES2 = [String1, String2, Response3, String4 ...] which is basically being read from a txt file. As you probably noticed, there might be some phrases (Response3) in the second list that are already present in the first list.

Is it possible to make VA say: "{TXT:RESPONSES1} {TXT:RESPONSES2}" but somehow make sure it doesn't select the same option twice? (i.e. it never says "Welcome back welcome back') Is there even a way to check the phrase VA has selected without it saying it?

I know I can do it in a plugin by comparing two variables and re-selecting one of them if they're the same. but I really like the simplicity of just reading it from a file (since I need this file anyway);

Antaniserse

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 87
    • My VA plugins
Re: Say {TXT:variable} but not same thing twice
« Reply #1 on: February 05, 2017, 09:04:49 AM »
I don't think you can expect this kind of very specific logic already integrated in VA so, one way or another, you have to code it yourself.

You can keep everything as it is now, text file and all, and just add an Inline function right before your TTS action that picks a unique combination from the two lists
"I am not perfect and neither was my career. In the end tennis is like life, messy."
Marat Safin

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Say {TXT:variable} but not same thing twice
« Reply #2 on: February 05, 2017, 09:21:58 AM »
Could try

If Response1 = Response2
    Say Response1
Else
    Say Response1 Response2
End If

Sorry for the brevity...  on my phone ;)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Say {TXT:variable} but not same thing twice
« Reply #3 on: February 05, 2017, 09:24:58 AM »
If you want deduplication between two variables, try this:
Code: [Select]
Marker: Readfromfile
Begin Text Compare : [RESPONSES1] Equals [RESPONSES2]
    Jump to Marker: Readfromfile
End Condition
Say, '{TXT:RESPONSES1} {TXT:RESPONSES2}'
Where the "Readfromfile" marker is placed at the point where you set the text variables by reading from your file, so it can re-set them if they're identical.

PsiQss

  • Guest
Re: Say {TXT:variable} but not same thing twice
« Reply #4 on: February 06, 2017, 05:03:24 AM »
Hmm, that's interesting. So the element of the response array is decided when reading from file? So technically, the variable contains only one phrase picked from phrase array in the file, am I right?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Say {TXT:variable} but not same thing twice
« Reply #5 on: February 06, 2017, 11:03:27 AM »
Hmm, that's interesting. So the element of the response array is decided when reading from file? So technically, the variable contains only one phrase picked from phrase array in the file, am I right?
No.

I had assumed you wrote your own randomizer, as Dynamic response sections are only supported by TTS itself, and from what I can tell only as the final step before sending the text to the speech engine.


As it turns out, what you're doing means neither mine nor Gary's suggestions will work, as the text that is proncounced is picked after any tokens are processed, so they cannot evaluate of affect it.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Say {TXT:variable} but not same thing twice
« Reply #6 on: February 06, 2017, 11:46:28 AM »
Yeah... I read that wrong.

How about this...  first read in each text variable:

myFirstResponse = (Read from file) Response1;Response2;Response3;Response4
mySecondResponse = (Read from file) Response5;Response6;Response3;Response4

Then extract the random portions:

Set myFirstResponse = {TXTRANDOM:myFirstResponse}
Set mySecondResponse = {TXTRANDOM:mySecondResponse}

Then do a compare:

If myFirstResponse = mySecondResponse
    Say myFirstResponse
Else
    Say myFirstResponse mySecondResponse
End If

PsiQss

  • Guest
Re: Say {TXT:variable} but not same thing twice
« Reply #7 on: February 07, 2017, 02:36:34 AM »
Oh yeah, that should work. Didn't know there was a TXTRANDOM token, totally solves the problem :D

Thanks a lot, guys!