Author Topic: Trying to use VoiceAttack for EDDI Voice (Solved)  (Read 2340 times)

blindside_o0

  • Newbie
  • *
  • Posts: 7
Trying to use VoiceAttack for EDDI Voice (Solved)
« on: November 28, 2021, 01:41:58 PM »
So I decided to reduce the amount of Automated machines talking in my ear during Elite Dangerous. I have Voice Attack, EDDI, and the standard Ship interface. I'm wanted to use Voice attack instead of EDDI since I like the techno effect I have placed on the voice and it gave me more options than just EDDI. Thanks to Pfeils response and a little extra tinkering I was able to get this running with no issues. Note I have an extra EDI integer as part of an overall if-then statement to avoid multiple calls for the same command, and a separate command for shutting the command sequence off. But aside from that, this is what I use to make EDDI talk through Voice Attack. I also have posted a youtube video to hear it in action. I do notice that the microphone and voice attack audio is rather quiet against the game audio but you get the idea. https://youtu.be/kjMtxJWBd-U

This command is executed When I say: Elite Data Interface
When this command executes, do the following sequence:
Code: [Select]
Set integer [~targetLine] value to 1
Set integer [~overallLines] value
Write (overwrite), " to file 'C:\Users\Blindside\AppData\Roaming\EDDI\speechresponder.out'
Say, 'Elite Data Interface [Initialized' or 'Enabled]' (and wait until it completes)
Start Loop While : [EDI] Equals 1
   Set text [~textFile] to [C:\Users\Blindside\AppData\Roaming\EDDI\speechresponder.out]
   Inline C# Function:
   Begin Integer Compare: [~targetLine] is Less Than [~overallLines]
      Inline C# Function:
      Write [Blue] '{TXT:~lineOutput}' to log
      Say,{TXT:~lineOutput}' (and wait until it completes)
      Set integer [~targetLine] to [~targetLine] plus 1
   End Condition
End Loop
Say, 'Elite Data Interface [Disabled' or 'Powered Down]' (and wait until it completes)

This command is executed When I say: [Shut Down;stop] Data Interface
When this command executes, do the following sequence:
Code: [Select]
Set integer [EDI] value to 0
Play sound, 'internal:Glugluglug'

The 1st Inline C# Function is:
Code: [Select]
public class VAInline
{
public void main()
{

//inputs of ~textFile and ~targetline
//Get output for current targetline
//get targetline value
string input = VA.GetText("~textFile");
if (input == null)
{
VA.WriteToLog("Cannot get line, no file set", "red");
return;
}

string[] lines = input.Split(new[] {Environment.NewLine}, StringSplitOptions.None);


VA.SetInt("~overallLines",lines.Length);
}
}

The 2nd Inline C# Function is:
Code: [Select]
public class VAInline
{
public void main()
{

//inputs of ~textFile and ~targetline
//Get output for current targetline
//get targetline value
string input = VA.GetText("~textFile");
if (input == null)
{
VA.WriteToLog("Cannot get line, no file set", "red");
return;
}

int targetLine = VA.GetInt("~targetLine") ?? -1;
if (targetLine < 1)
{
VA.WriteToLog("Cannot get line, no or invalid line number set", "red");
return;
}

string[] lines = input.Split(new[] {Environment.NewLine}, StringSplitOptions.None);

if (targetLine > lines.Length)
{
VA.SetInt("~targetLine",targetLine);
VA.WriteToLog("Warning: Target line is " + targetLine + ", but the file only contains " + lines.Length + " lines", "orange");
return;
}

VA.SetText("~lineOutput", lines[targetLine-1]);
}
}
[code]
« Last Edit: November 28, 2021, 10:11:18 PM by blindside_o0 »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4692
  • RTFM
Re: Trying to use VoiceAttack for EDDI Voice
« Reply #1 on: November 28, 2021, 02:03:11 PM »
That message would appear if you're passing the TTS action an empty value.


Start by enabling the "Wait for the inline function to finish before continuing" option for both of the inline functions.

Without that, the action is executed asynchronously and a race condition can occur, where the TTS action is executed before the inline function has completed.

blindside_o0

  • Newbie
  • *
  • Posts: 7
Re: Trying to use VoiceAttack for EDDI Voice (SOLVED)
« Reply #2 on: November 28, 2021, 08:44:57 PM »
PFEIL! thank you for your reply. I got it working JUST NOW.
Honestly was hoping you would reply to this given that the C# is based off of your post.
https://forum.voiceattack.com/smf/index.php?topic=3756.0
I had the code Write out the text before it reads it so I could tell what it was going to try sending out.
It turns out that following code needed to be "Less than" not "Less than or Equal to"
Code: [Select]
Begin Integer Compare:[~targetLine] is Less Than [~overallLines]

For those who have been following, I placed all the information into my primary post so you don't need to look at the rest  ;) Happy Coding
« Last Edit: November 28, 2021, 10:13:19 PM by blindside_o0 »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4692
  • RTFM
Re: Trying to use VoiceAttack for EDDI Voice (Solved)
« Reply #3 on: November 29, 2021, 04:27:06 AM »
It turns out that following code needed to be "Less than" not "Less than or Equal to"
Code: [Select]
Begin Integer Compare:[~targetLine] is Less Than [~overallLines]

The last available index is one less than the total amount of items, as indices start counting at zero (zero-indexing), whereas the amount of items starts counting at one (as mentioned in the topic you linked)

E.G. if you have three items, "~overallLines" would have a value of 3, but the available indices would be 0, 1, and 2