Apr.11

Opentx Automated SAPI5 Voice Generator

​Hey fellow OpenTX users!

I've been procrastinating whilst writing up my thesis, at the end of finishing up a rather long Matlab script I thought wouldn't it be great to be able to use Matlab to generate and save SAPI5 voice packs for my favorite TX, the FrSky Taranis.
Starting off with an Excel spreadsheet containing a list of the text to be read, the directory structure and the file name, this was imported into Matlab 2010 x32 (yep, it is the 32bit version, I have only been able to find a x32 version of the dll required for this script to work, I simply don't have enough time to procrastinate long enough to write my own x64 version). Then set up a few variables and a small looping script to take the text, file name and directory, read out the text in your favourite voice flavour then save the files into a new folder.

The script is as follows: rting off with an Excel spreadsheet containing a list of the text to be read, the directory structure and the file name, this was imported into Matlab 2010 x32 (yep, it is the 32bit version, I have only been able to find a x32 version of the dll required for this script to work, I simply don't have enough time to procrastinate long enough to write my own x64 version). Then set up a few variables and a small looping script to take the text, file name and directory, read out the text in your favourite voice flavour then save the files into a new folder.

The script is as follows:

rting off with an Excel spreadsheet containing a list of the text to be read, the directory structure and the file name, this was imported into Matlab 2010 x32 (yep, it is the 32bit version, I have only been able to find a x32 version of the dll required for this script to work, I simply don't have enough time to procrastinate long enough to write my own x64 version). Then set up a few variables and a small looping script to take the text, file name and directory, read out the text in your favourite voice flavour then save the files into a new folder.

The script is as follows:

Code:

% Set up the initial parameters
clear all;close all;
load('TaranisVoiceData.mat');
Fs   = 32000;
N     = 228;
R     = 2;
Voice = 3;
FileName = 2;
Directory = 1;
Speed = 0; %range goes from -5 to 5
Nbits = 16;
% Extract all words, file paths and file names
for R = 2:N
% the first one is a string
if R == 1
VoiceList{R-1,Voice} = cellstr(textdata(R,Voice)); % use this for cells that contain 'strings'
VoiceList{R-1,FileName} = cellstr(textdata(R,FileName)); 
VoiceList{R-1,Directory} = cellstr(textdata(R,Directory)); 
else
% the next 2 to 110 are numbers
if R >= 2
if R <= 110
VoiceList{R-1,Voice} = num2str(textdata{R,Voice}); % use this for cells that contain numbers
VoiceList{R-1,FileName} = num2str(textdata{R,FileName}); 
VoiceList{R-1,Directory} = num2str(textdata{R,Directory}); 
elseif R > 110
VoiceList{R-1,Voice} = num2str(textdata{R,Voice}); % use this for cells that contain numbers
VoiceList{R-1,FileName} = num2str(textdata{R,FileName}); 
VoiceList{R-1,Directory} = num2str(textdata{R,Directory}); 
end
end 
end
end
%% Now to convert the text into speech and save
Y=1;
for Y=1:N
if Y==227
break
end
VoiceTemp = VoiceList(Y,3);
w = tts(char(VoiceTemp),'VW Kate',Speed,Fs);
currentPath = pwd; % Get the current working directory
[~,~,~] = mkdir(strcat(currentPath,'\SOUNDS'),'EN'); % make a new directory to store the files in ../EN & ../EN/SYSTEM
[~,~,~] = mkdir(strcat(currentPath,'\SOUNDS\EN'),'SYSTEM'); % make a new directory to store the files in ../EN & ../EN/SYSTEM
currentPath = strcat(currentPath,'\',VoiceList{Y,Directory},'\',VoiceList{Y,FileName}); % get the full file path
SaveToHere = currentPath; % store full file path in temp variable
% Save the file
wavwrite(w,Fs,Nbits,currentPath);
Y %counter to monitor progress
end

The files are available here:

Thanks to Siyi Dend who wrote the initial TTS script used in this release.


One last thing, to get a list of all the voices that you have available on your computer system just open up Matlab, open the working directory where you have saved the files downloaded from the section above, then in the console type in:
tts('','List');

Matlab will print out a list of all available voices on your PC. You can see in the script file I have used the 'VW Kate' SAPI5 voice pack, if you remove the 'VW Kate' and make it like this:

w = tts(char(VoiceTemp),'',Speed,Fs);

the script will use the default terrible Microsoft Mike or Anna voice, which is rather deplorable, so jump online and Google free SAPI5 voices, there are plenty to be found. See the figure below for an example list.


So with all of that out of the way, I hope that this script may become of use to someone in the community.
Let me know if there are any bugs and I'll try to fix them when I get another opportunity to procrastinate =)
Cheers & happy flying,
L

Uncategorized
Share this Story:
  • facebook
  • twitter
  • gplus

About Luke Nyhof

Luke is a professional Engineer working in the defense and space sector in Australia. He brings a unique blend of innovation and skills to the development of Australian UAx defense technology.

Previously employed in the Telecommunications industry as a Technical Manager supporting innovative geospatial data exploration and visualisation tools enabling strategic network planning. His role at the company as Integration Data Interlock Engineer gave light to his work on predictive maintenance systems, machine learning and network operations & geospatial analytics.

Luke's post-graduate career path began at the Centre for Intelligent Systems Research (CISR, now named The Institute for Intelligent Systems Research & Innovation, IISRI), where he was an active and published academic who's engineering research projects included robust adaptive signal processing for biomedical applications, robotic systems, autonomous ground vehicles and advanced robotic motion simulators.

Before joining the Centre he completed his bachelor's degree in engineering, majoring in Mechatronics and Robotics graduating with 1st Class Honours. During this time he was also employed by Robert Bosch Australia. Based at the Australian Automotive Research Complex in Anglesea, the role gave him the opportunity to work as part of a highly competent team of engineers developing chassis control systems for development vehicles. He truly passionate about his work and always eager to connect with other researchers for collaboration.

While Luke have been involved in both collaborative and independent work, his favorite part of project work has been in developing unique solutions for intriguing problems.

Comments(1)

  1. Best SEO Service
    1613 days ago

    Awesome post! Keep up the great work! 🙂

Leave a comment

Comment