Author Topic: How can I get a VA routine "Say" a variable read from a text file?  (Read 1608 times)

JBlyth

  • Newbie
  • *
  • Posts: 2
I have looked everywhere, but I can't seem to find a method of getting VA "say" a text variable.

I have made a quick VB script within VA to get the data into a variable, but I can't for the life of me find a way to get VA to actually "say" the variable.

I would have imagined that the 'VA.ExecuteCommand("myCommand") might be a way, but I can't work out the syntax.

Or is it possible to pass a variable to the standard "Say Something with Text-To-Speak" action a simpler solution?

Any assistance would be greatly appreciated.

Cheers
John in Sunny Carnarvon - Western Australia

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Data
Imports System.Drawing
Imports System.Diagnostics
Imports System.Windows.Forms
Imports System.Linq
Imports System.Xml.Linq
Imports System.Threading.Tasks

Public Class VAInline

   Public Sub Main()
   dim text,FileName,fso,MyFile,SpeakText
   FileName="C:\Users\xxxxxxxxxxxxxxx\OneDrive\Desktop\Condor\StartFinishHeights.txt"
   fso = CreateObject("Scripting.FileSystemObject")
   MyFile=fso.OpenTextFile(FileName, 1, True)
   SpeakText=MyFile.ReadAll
   Msgbox(SpeakText)
   VA.ExecuteCommand(say, SpeakText) 'THIS DOESN"T WORK  :'(

   End Sub

End Class

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: How can I get a VA routine "Say" a variable read from a text file?
« Reply #1 on: March 18, 2022, 09:49:25 AM »
Press F1 while VoiceAttack has focus to open VoiceAttackHelp.pdf in your default PDF viewer, which contains information on VoiceAttack's features.

You don't need an inline function to read the contents of a text file, nor to have a "Say Something with Text-To-Speech" action speak the contents of a variable.

These (sub)sections should be of particular interest:
'Set a Text Value'
Text (and Text-To-Speech) Tokens


This topic may also be of use, in addition to the official documentation:
Variables and tokens summed up

JBlyth

  • Newbie
  • *
  • Posts: 2
Re: How can I get a VA routine "Say" a variable read from a text file?
« Reply #2 on: March 18, 2022, 07:00:55 PM »
Thank you, Pfeil,

Your suggestions lead me to a very easy solution in 2 minutes! I  had previously looked quite thoroughly through the extensive manual, but I just needed to be pointed in the correct direction.

Set text [SpeakText] to [C:\Users\xxxxxxxx\OneDrive\Desktop\Condor\StartFInishHeights.txt]
Say, ' {TXT:SpeakText}'

Cheers
John

SemlerPDX

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 279
  • Upstanding Lunatic
    • My AVCS Homepage
Re: How can I get a VA routine "Say" a variable read from a text file?
« Reply #3 on: March 21, 2022, 12:51:46 PM »
On the topic of TTS from an inline, is there a proxy for the say-something-with-tts for direct use in an inline, or would the method simply be to set a text variable, then execute a command which merely speaks whatever is in said text variable?

like Pfeil said, no need to get into inlines if you're not already using them, Say Something with Text to Speech is a common action under 'Other > Sounds'

(for OP, syntax that WOULD make that work from an inline, if already using an inline, would be found in the manual in the "Plugins for the Truly mad", search for 'vaProxy.Command.Execute', but this is also available under the VA. options, presented in a list when you type "VA.", so 'Command.' and then 'Execute')

like this (in VB.net inlines):
Code: [Select]
VA.SetText("~ExampleMyTTSvar", "the thing I want to be said")
VA.Command.Execute("Example My Command Phrase", true, false, nothing, "~ExampleMyTTSvar")

...and then inside the command "Example My Command Phrase", you can access this text variable under "~passedtext1"
like this:

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: How can I get a VA routine "Say" a variable read from a text file?
« Reply #4 on: March 21, 2022, 01:11:12 PM »
Generally, actions cannot be executed directly by inline functions, no.


You can set a variable, and then use a command that retrieves that value of that variable specifically, or you can pass values using the optional parameters of the Execute() method (double quotes are required when passing literal text) and use the generated local variable names.
Either one would be combined with a token in the "Say Something with Text-To-Speech" action, of course.

Passing values would also allow you to set a variable, and then pass the name of that variable to the command, rather than the literal value, to avoid wrapping it in quotes, if you prefer.

SemlerPDX

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 279
  • Upstanding Lunatic
    • My AVCS Homepage
Re: How can I get a VA routine "Say" a variable read from a text file?
« Reply #5 on: March 21, 2022, 08:03:49 PM »
Awesome, thanks!  I always wondered that, glad it came up in this thread!  I did look everywhere, but came up empty, scrolled through the listboxes that come up when you type VA. in the inline editor, figured it either didn't exist or was so buried I was overlooking it repeatedly.

Cheers!