and again dll and market - page 14

 
Ре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...
 
Someone try running the .wav from the Files folder. I wonder if it works.))
 
//+------------------------------------------------------------------+
//|                                                       Sounds.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                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   PlaySound("\\Files\\Sounds\\alert.wav");
   Sleep(1*1000);
   PlaySound("\\Files\\Sounds\\request.wav");
   Sleep(1*1000);
   PlaySound("\\Files\\Sounds\\email.wav");
  }
//+------------------------------------------------------------------+
Реter Konow
:

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\
 
Alexsandr San:

yes it works I copied the entire folder

Now that, that's the hope.))
 
Реter Konow:
Now that, that's hope.))

double-checked the song and ran it again

   Sleep(1*1000);
   PlaySound("\\Files\\Sounds\\Kazka.wav");
https://yadi.sk/d/EGsTJGYBmDFnGg
 
Alexsandr San:

double-checked the song again ran

https://yadi.sk/d/EGsTJGYBmDFnGg
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

                     ObjectsDeleteAll(0,InpObjDownNameG);
                     IndicatorDelete();
                     PlaySound("ok.wav");
                     if(InpChartInd && Obj_SELLChartInd())
                        return;

of course its own melody or sound

 
Serhii Shevchuk:

I can take a look, but not before tomorrow evening. If you haven't worked it out yourself by then.

Maxim Kuznetsov:

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


curl -X GET -u ^
apikey:GR1bb3zVMs9fcNKL6pA9-5 zj9ptWliCu6eh9oupUnpZB ^
--output hello_world.wav ^
https://api.eu-gb.text-to-speech.watson.cloud.ibm.com/instances/9886a3ce-5734-455f-8f78-7a56381da686/v1/synthesize?text=TEST

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                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   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);
           }
         else
            Print("Ошибка в FileOpen. Код ошибки =",GetLastError());
        }
      else
         PrintFormat("Ошибка загрузки '%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"

Can you give me a hint? ))

 
Nikolai Karetnikov:

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? ))

What does error 401 mean?
 

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.