Trying to run the example-basic-speak project for @kashim 's ofxEspeakSynth but getting linking errors, similar to the ones reported here. Here’s one of them :
Severity
Code
Description
Project
File
Line
Suppression State
Error
LNK2019
unresolved external symbol espeak_Initialize referenced in function public: void __cdecl ofxEspeakSynth::setup(struct ofxEspeakSynth::ESParam) (?setup@ofxEspeakSynth@@QEAAXUESParam@1@@Z)
the project generator generated solution includes ofApp.cpp and ofApp.h, even though they don’t exist (the example runs everything in main.cpp). I was getting an error that they didn’t exist, so I restructured the project to include an ofApp.cpp and .h files, though it seems I could also have just removed ofApp.cpp and ofApp.h from the solution explorer.
ofxEspeakSynth.h contains #include <espeak/speak_lib.h>, which threw an error. So I copied my eSpeak folder (the one linked to on the git repo) into src and replaced that line with #include"eSpeak/docs/speak_lib.h" . This gets rid of the intellisense error, but not the linking errors.
Any general advice on figuring out linking problems like this is appreciated. Any advice specific to ofxEspeakSynth is also appreciated. And if there’s a better way of getting text-to-speech in my project, I’d be grateful to know about that as well.
Hi, well you need to link against the library. I feel taht the easiest way is to put the static library into the addon, and make sure you put the necesary stuff in the addon_config.mk file.
If it does no works you can link “manually” by adding the library in the project settings. WHich IDE are you using?
Hi, you need to link to the DLL . Dont change those #include calls. if you get there an error it means it is being found.
In Visual Studio go to project preferences Linker > Input and add to field Additional Dependencies the espeak dll. not sure which is the exact name of it, but yuo should install it first.
let me know how it goes.
did this in Visual Studio 2012. But I think it works in previous versions, as well.
Find the LIB or other file you want to add to your project in Windows Explorer. Drag the LIB file from Windows Explorer onto Visual Studio’s Solution Explorer, to the project to which you wish to add the LIB file. Now, you will see the file listed in Solution Explorer.
That’s it! Just one step! You will not see the file in “Project Properties → Linker → Input → Additional Dependencies.” However, it is there hidden in the macro %(AdditionalDependencies).
I did this- as you can see, there’s the espeak_sapi.dll in the browser on the right- and it didn’t work. That is a very old version of VS they were referring to though- any other ideas?
Hi, it kinda does not matter if you just add it by drag and drop, iy neds to be added to the properties panel. If you clic on the field that says %(AditionalDependencies) a dropdown that says something like Edit will show. Choose it and there you’l see fields to add more stuff. Add in it by its name. speak_sapi.dll
OK, I’ve tried doing as you said, but now I just get a single “cannot open input file ‘espeak_sapi.dll’ error”. Any other ideas? There are no other .dll or .lib files in this directory…
does the espeak library have an installer? if so, where does it install its files? do you know where thte espeak_sapi.dll file is?
if it is in a “non conventional” path you might need to add the path to the additional library paths.
It installed from the installer into ProgramFiles(x86), but I copied that whole folder into the src folder of this example project, and assigned that copy’s dll in the solution explorer and configuration properties>linker>input page. (should I not have done that?)
As per the link you sent me, I’ve just tried setting the path of the same directory to ConfigurationProperties>Linker>General>AdditionalLibraryDirectories field:
Hi, I dont think it is a good idea to put the whole espeak folder into src.
it is better if you follow the structure of the libs folder of ofxAddonTemplate.
Once done refresh your project with project generator
OK, @roymacdonald … I’ve put the whole espeak folder into addons/ofxEspeakSynth/libs/eSpeak . Just like the example addon project, the header file is one level lower than that (in the “docs” folder instead of “include”). Then I regenerated the project.
I guess this did something because the errors I get now are different- much cleaner than the long error messages in my first post:
Trying to include the dll in the way you said replaces the above errors with the same same LNK1107 error. Looking this up, users on StackOverflow said this error is because you’re not supposed to explicitly include .dll files, but .lib files. However, I don’t see a .lib file for this.
(I also wondered if the espeak_sapi.dll was a mispell and tried renaming it to espeak_api.dll, but this didn’t help)
Hey,
which files you’ve got in the espeak folder.?
Yes, it does not go inside include. but it is not that you simply put the folder you´ve got. It requires to follow a certain structure, so PG know where to look at when including an addon into a project.
just thinking outloud (as trying to get a lib with binary lib to link correctly is probably one of the most draining C++ thing…) if your goal is simply to get speech out of the machine maybe ofSystem() can get you there – for instance on a Mac:
will have the system say “hello world” with the Sandy voice – perhaps you can use espeak on windows in a similar manner? (assuming you don’t need the fancy callbacks).
@roymacdonald The structure when installing from the link provided in the addon’s readme is
-eSpeak/
-command_line/
-espeak.exe
-dictsource/
-af_list
-af_rules
-am_list...
-(etc., all the eway down to zhy_rules)
-docs/
-images/
-lips.png
-sand-light.jpg
-add_language.html
-analyse.html...
-(about 12 other html files)
-speak_lib.h
-espeak-data/
-mbrola/(empty folder)
-mbrola_ph/
-(about 40 files from af1_phtrans to vz_phtrans)
-soundicons/(empty)
-voices/
-!v/(about 20 files from croak to whisperf)
-asia/(about 20 files from fa to zh-yue)
-europe/(about 20 files from an to sv)
-mb/(about 40 files from mb-af1 to mb-vz1)
-other/(about 10 files from af to sw)
-test/(about 15 files from am to ur)
-de
-default
-en
-en-us
-es-la
-fr
-pt
-(about 50 files from af_dict to zhy_dict)
-ChangeLog.txt
-espeak_sapi.dll
-License.txt
-Readme.txt
-TTSApp.exe
-unins000.dat
-unins000.exe
@burton Looks like the syntax is trickier on Windows. I tried two of the methods in the top answer here and they both work in the command prompt, but not when called via ofSystem (I used \ before the inner quotation marks to avoid escaping the string): cmd - ms speech from command line - Stack Overflow
Also, I’ve tried looking up how to do text-to-speech in c++ and a lot of the scripts start with using namespace System
which doesn’t seem to be accessible in my oF project…
i don’t have a windows machine to try things but i know both on mac and linux the quoting, spaces and paths can be very sensitive. as you say those windows prompt seem pretty involved with parenthesis and semi-colons – maybe there are more escapes needed.
can you get something else with a similar syntax complexity working via ofSystem()? just to make sure you have the correct “format” for the string being passed, start from a simple command and build progressively.
(might be a bit boring but it may translate to many other functions so not a bad time investment)
@burton Assuming ofSystem should just behave like the command prompt, I tried ofSystem("ipConfig"); and even this doesn’t work (ie. it doesn’t print out my ipConfig info into the oF console window).
Hi,
the .msi you download is an installer so probably it is installing the library as a system wide library.
there is no problem using the C library. Actually it seems to be calling the same functions that the addon does.
Building is another option. That should generate the library if it is set up as such (which I guess it is).
pulling the files directly from the source folder might work but also it might miss some preprocessor directives and other build instructions.
You can also integrate the visual studio project that the library brings into your project and build all at once, the same way as OF is being used.