If I want to export audio as either a wav or an mp3 from the symbols in Watchlist 0 for text-to-speech TTS accessibility...
How can I use Say() function to encode and create the wav or mp3 file to then export?
This is TTS-Test2.afl code
_VoiceNumber = Param("VoiceNumber",9,0,11,1);
VoiceSelect(_VoiceNumber);
//VoiceSelect(9); // Is this a persistent variable as it will not refresh for all voices when I change the number?
_Fullname = FullName();
_SayThis = "AmiBroker is really amazing software to chart " + _Fullname;
AddTextColumn(_SayThis, "_SayThis");
Say(_SayThis, purge=True);
// how can I export variable "_SayThis" from each symbol in Watchlist 0 - as an .mp3 file?
// do I have to create a .wav file and then convert that to an .mp3?
// Can this be done thru a separate .js file via ShellExecute as well? - functioning Watchlist 0 parsing code below
Here is what I have so far...
// To be placed in AmiBroker/Scripts directory
// WL0_ExportAudio.js
iWatchList = 0; // you can define watch list number here
DateObj=new Date();
D=DateObj.getDate();
M=(DateObj.getMonth()+1);
Ye=DateObj.getYear();
H=DateObj.getHours();
mi=DateObj.getMinutes();
AB = new ActiveXObject("Broker.Application");
Qty = AB.Stocks.Count;
for( i = 0; i < Qty; i++ )
{
Stk = AB.Stocks( i );
// exportfolder = "C:\\DataExport\\" + Stk.Ticker + ".wav";
// export file name with date format = "Symbol_YYYYMMDD_HH-MM"
//exportfolder = "C:\\DataExport\\" + Stk.Ticker + "_"+Ye+M+D+"_"+H+"-"+mi+ ".wav";
exportfolder = "C:\\DataExport\\" + Stk.Ticker + "_"+Ye+M+D+"_"+H+"-"+mi+ ".mp3";
if( iWatchList < 32 )
{
if( Stk.WatchListBits & ( 1 << iWatchList ) )
{
AB.ActiveDocument.Name = Stk.Ticker;
WScript.Sleep( 100 ); // 0.1 sec wait
AB.ActiveWindow.ExportAudio( exportfolder , channels: 1, sampleRate: 16000, bitDepth: 128);
}
}
else
{
if( Stk.WatchListBits2 & ( 1 << ( iWatchList - 32 ) ) )
{
AB.ActiveDocument.Name = Stk.Ticker;
WScript.Sleep( 100 ); // 0.1 sec wait
AB.ActiveWindow.ExportAudio( exportfolder );
}
}
}
//notify the user when finished
Shell = new ActiveXObject("WScript.Shell");
Shell.Popup("Audio file(s) exported to file - Done!", 10.0);
Thanks in Advance.