and again dll and market - page 12

 
nkaretnikov:

there is no need to write to the file. WebRequest method formats

What does "download" mean? The sound file obtained after the text conversion should be placed in the Sounds folder in order for the Expert Advisor to play it. The sound is created in EA by PlaySound function, not WebRequest, and it takes an audio file from Sounds folder. I'm telling you that the task is almost impossible.
 
Реter Konow:
What do you mean "download"? The sound file obtained after text conversion must be placed in the Sounds folder for the Expert Advisor to play it. The PlaySound function, not WebRequest, creates the sound in the Expert Advisor, and it takes an audio file from the Sounds folder. I'm telling you that the task is almost impossible.

yep...

it's impossible to play a wav file from a sandbox without a DLL?

 
nkaretnikov:

yep...

it's impossible to play a wav file from a sandbox without a DLL?

How will it end up in the sandbox? After conversion, you need to put the resulting file in the sandbox. Webrequest will not do this. How do you write it automatically into the Sounds folder?
 
Реter Konow:
How will it end up in the sandbox???

I assume that the result of the WebRequest will be a WAV file downloaded from the server. Here is the result of the following code

//+------------------------------------------------------------------+
//|                                                   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 = headers + "-u apikey:GR1bb3zVMs9fcNKL6pA9-5zj9ptWliCu6eh9oupUnpZB";
   headers = headers + " --header \"Content-Type: application/json\"";
   headers = headers + " --header \"Accept: audio/wav\"";
   headers = headers + " --data \"{\"text\":\"hello world\"}\"";
   headers = headers + " --output hello_world.wav";
//output hello_world.wav ^

   string url="https://api.eu-gb.text-to-speech.watson.cloud.ibm.com";
//--- для работы с сервером необходимо добавить URL "https://finance.yahoo.com"
//--- в список разрешенных URL (Главное меню->Сервис->Настройки, вкладка "Советники"):
//--- обнуляем код последней ошибки
   ResetLastError();
//--- загрузка html-страницы с Yahoo Finance
   int res = WebRequest("POST",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);
     }
  }
//+------------------------------------------------------------------+



the problem at this stage is that hello_world.wav comes up empty, because the format of the WebRequest call is clearly wrong

 
Nikolai Karetnikov:

I assume that the result of the WebRequest will be a WAV file downloaded from the server. Here is the result of the following code



the problem at this stage is that hello_world.wav comes up empty, because the format of the WebRequest call is clearly wrong

Even if you get a valid sound file from server to EA via socket or webrequest, you cannot write it to Sounds folder, so PlaySound will not be able to play it.
 
Реter Konow:
Even if you get a valid sound file from the server to the EA via socket or webrequest, you cannot write it to the Sounds folder, which means that PlaySound will not be able to play it.

IsPlaySound the only option to play a wav file without a DLL?

 
Nikolai Karetnikov:

Is PlaySound the only option to play a wav file without a DLL?

Yes.
 
Реter Konow:
Even if you get a valid sound file to the EA from the server via socket or webrequest, you cannot write it to the Sounds folder, which means that PlaySound will not be able to play it.

see above on the subject - anything is possible, but requires the will of the user

 
Реter Konow:
Yes.

shitty )

 
Реter Konow:
Yes.

wait, what about this

//--- play sound file Demo.wav from terminal_data_directory\MQL5\Files\
PlaySound("\\\Files\\\Demo.wav")

https://www.mql5.com/ru/docs/runtime/resources

Документация по MQL5: Программы MQL5 / Ресурсы
Документация по MQL5: Программы MQL5 / Ресурсы
  • www.mql5.com
В данном примере показано как проигрывать звуки из файлов Ok.wav и timeoit.wav, входящих в стандартную поставку терминала. Эти файлы находятся в папке означает папку, из которой запущен клиентский терминал MetaTrader 5.  Программным путем из mql5-программы каталог терминала можно узнать следующим образом: Расположение каталога данных терминала...