Реter Konow: If a sound file can be played from the Files folder, where it is pre-recorded by the Expert Advisor, then the solution of the problem will be real, if the resulting sound file will be integral.
No! The documentation says that sound files should be stored in the Sounds folder.
https://www.mql5.com/ru/docs/common/playsound
This is a critical issue for the topic. If the file won't play from the Files folder, then PlaySound is out of the question. Then there is no need to return anything from the server. Why? Unless PlaySound suddenly fails to work with the EA's internal resource, which I highly doubt...
Well, then you don't always have to believe the documentation)))
Now, if the TC will receive valid audio files from the server, then re-recorded in one place and play on the fly, then the task of universal solution for the voiceover of text messages to the user will be solved.
ZS. Can PlaySound also play the sound from internal resources created by EA? Then there is no need to write the file to Files. Immediately save the file to the resource and play it.
Реter Konow: Well, you don't always have to believe the documentation)))
Now, if the TC will receive valid sound files from the server, then re-record them in one place and play them on the fly, then the problem of universal solution of voice-over of text messages to the user will be solved.
ZS. Maybe PlaySound can play the sound from internal resources created by EA?
I do not know, in my Expert Advisor - where there is some action, it plays
i use it to download a wav file with the word TEST in it
then remove options
//+------------------------------------------------------------------+//| WebRequest.mq5 |//| Copyright 2020, MetaQuotes Software Corp. |//| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright"Copyright 2020, MetaQuotes Software Corp."#property link"https://www.mql5.com"#property version"1.00"//+------------------------------------------------------------------+//| Script program start function |//+------------------------------------------------------------------+voidOnStart()
{
string cookie=NULL,headers;
char post[],result[];
char cost_char_data[];
string result_headers;
headers = "-u apikey:GR1bb3zVMs9fcNKL6pA9-5zj9ptWliCu6eh9oupUnpZB --output hello_world.wav";
string url="https://api.eu-gb.text-to-speech.watson.cloud.ibm.com/instances/9886a3ce-5734-455f-8f78-7a56381da686/v1/synthesize?text=TEST";
ResetLastError();
int res = WebRequest("GET",url,headers,1000,cost_char_data,result,result_headers);
if(res==-1)
{
Print("Ошибка в WebRequest. Код ошибки =",GetLastError());
//--- возможно, URL отсутствует в списке, выводим сообщение о необходимости его добавленияMessageBox("Необходимо добавить адрес '"+url+"' в список разрешенных URL во вкладке 'Советники'","Ошибка",MB_ICONINFORMATION);
}
else
{
if(res==200)
{
//--- успешная загрузкаPrintFormat("Файл успешно загружен, размер %d байт.",ArraySize(result));
//PrintFormat("Заголовки сервера: %s",headers);//--- сохраняем данные в файлint filehandle=FileOpen("output hello_world.wav",FILE_WRITE|FILE_BIN);
if(filehandle!=INVALID_HANDLE)
{
//--- сохраняем содержимое массива result[] в файлFileWriteArray(filehandle,result,0,ArraySize(result));
//--- закрываем файлFileClose(filehandle);
}
elsePrint("Ошибка в FileOpen. Код ошибки =",GetLastError());
}
elsePrintFormat("Ошибка загрузки '%s', код %d",url,res);
}
}
//+------------------------------------------------------------------+
in the header now is the authorization option -u, behind which the server waits for the apikey. Seems to make sense, but something in the syntax is still wrong
code result -"Webrequest4Voice (EURCHF,D1) Error loading 'https://api.eu-gb.text-to-speech.watson.cloud.ibm.com/instances/9886a3ce-5734-455f-8f78-7a56381da686/v1/synthesize?text=TEST', code 401"
so where can we get an example with output to a binary file!? ))
trying to figure it out, i've minimized the syntax of the url command itself
download a wav file with the word TEST in it
then remove options
in the header now is the authorization option -u, behind which the server waits for the apikey. Seems to make sense, but something in the syntax is still wrong
code result -"Webrequest4Voice (EURCHF,D1) Error loading 'https://api.eu-gb.text-to-speech.watson.cloud.ibm.com/instances/9886a3ce-5734-455f-8f78-7a56381da686/v1/synthesize?text=TEST', code 401"
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
If a sound file can be played from the Files folder, where it is pre-recorded by the Expert Advisor, then the solution of the problem will be real, if the resulting sound file will be integral.
Somebody try running the .wav from the Files folder. I wonder if it works.))
yes it works I copied the entire folder
C:\Users\San\AppData\Roaming\MetaQuotes\Terminal\3 DE8A6E768D9369994F541727D733DE8\MQL5\Files\Sounds\yes it works I copied the entire folder
Now that, that's hope.))
double-checked the song and ran it again
https://yadi.sk/d/EGsTJGYBmDFnGgdouble-checked the song again ran
https://yadi.sk/d/EGsTJGYBmDFnGgWell, you don't always have to believe the documentation)))
I do not know, in my Expert Advisor - where there is some action, it plays
of course its own melody or sound
I can take a look, but not before tomorrow evening. If you haven't worked it out yourself by then.
and you won't :-)
why do you put curl command options in HTTP headers?
Why don't you at least read some books, look through some examples... otherwise, we'll all write you an article
so where can i get an example with output to a binary file? ))
trying to figure it out, i've minimized the syntax of the url command itself
i use it to download a wav file with the word TEST in it
then remove options
in the header now is the authorization option -u, behind which the server waits for the apikey. Seems to make sense, but something in the syntax is still wrong
code result -"Webrequest4Voice (EURCHF,D1) Error loading 'https://api.eu-gb.text-to-speech.watson.cloud.ibm.com/instances/9886a3ce-5734-455f-8f78-7a56381da686/v1/synthesize?text=TEST', code 401"
Can you give me a hint? ))
so where can we get an example with output to a binary file!? ))
trying to figure it out, i've minimized the syntax of the url command itself
download a wav file with the word TEST in it
then remove options
in the header now is the authorization option -u, behind which the server waits for the apikey. Seems to make sense, but something in the syntax is still wrong
code result -"Webrequest4Voice (EURCHF,D1) Error loading 'https://api.eu-gb.text-to-speech.watson.cloud.ibm.com/instances/9886a3ce-5734-455f-8f78-7a56381da686/v1/synthesize?text=TEST', code 401"
Can you give me a hint? ))
To translate an HTTP request from curl options to WebRequest parameters, you have to:
1. in general, look at wikipedia to see how HTTP is structured
2. check in Curl documentation to see what options mean and why they are used
3. read the WebRequest help and see examples, even in this thread a lot
4. You should write code being aware of what you've done :-) what, why and why is it used.
You are obviously expecting all 4 points to be done for you. I understand it's weekend, time is short, and you have lots of ideas. It has to be quick.
But you still have to do it yourself.