and again dll and market - page 13

 
nkaretnikov:

it is not possible to play a wav file from a sandbox without a DLL?

from help

For example, if audio file Demo.wav is located in terminal_data_directory\MQL5\Files folder, then PlaySound() call should be written in this way:

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

The problem is that the playsound engine itself is flawed. it doesn't combine the sounds, but stops playing the previous one as soon as a new command arrives.

There is a requirement in the market that the product should work out of the box and not depend on third party modules. but it is possible to make a radical move - to make a box solution on playsound crutch and if you have some module, for example, posted in kodobase, use a normal solution through the win engine. which I understand can also do text recognition.

 
nkaretnikov:

I see you are an experienced person, can you help me write a socket reference example?

The documentation is herehttps://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-usingWebSocket

I understandinstance_id is GR1bb3zVMs9fcNKL6pA9-5zj9ptWliCu6eh9oupUnpZB

While I'm reading the doc...

What exactly is your query failing? There are good examples in the documentation.

I don't have time now, and it's useless thing.

Regarding your link - if you can not use WebSocket - better not to use, you will save a lot of time (if you have no experience with it). There are other options out there besides WebSocket.

Документация по MQL5: Сетевые функции / SocketCreate
Документация по MQL5: Сетевые функции / SocketCreate
  • www.mql5.com
//|                                                SocketExample.mq5 | //|                        Copyright 2018, MetaQuotes Software Corp. | //|                                             https://www.mql5.com | //| Отправка команды на сервер                                       |...
 
Andrei Trukhanovich:

from help

For example, if Demo.wav sound file is located in terminal_data_directory\MQL5\Files folder, PlaySound() call should be written in this way:

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

The problem is that the playsound engine itself is flawed. it doesn't combine the sounds, but stops playing the previous one as soon as a new command arrives.

the market requires that the product should work out of the box and not depend on third party modules. but it is possible to make a radical move and make a box solution on playsound crutch and if you have some module, for example in kodobase, use a normal solution through the wind engine. which I understand can do text recognition too.

that's my point exactly! )

Yes, 2 ways.

The 1st way is PlaySound and pauses based on pronunciation speed. But I encountered this and at the stage of calling the native Windows TTS features, when the second phrase gets into a busy stream, we get a runtime error. Therefore, there is a delay in the class based on the pronunciation speed of 100 characters per minute. In principle, we get out of this situation.

Method 2 - Generate test file by closed code and play it back by open code with enabled DLLs

 
Serhii Shevchuk:

Why write something unnecessarily in the folder? PlaySound can play from resources, see "Using Resources" in the link

P.S. I haven't tried it myself, but since it's written in the documentation, it must be possible.

Well, the computer wants a universal solution where we don't need to integrate sound resources into the Expert Advisor. He wants to design a system of interaction between the Expert Advisor and the server, in which the first creates a text file of words that NOW needs to be said by the user, and the server converts them to .wav and sends back to the Expert Advisor. Next, the Expert Advisor, unknowingly, writes the file in place of the previous file (with the previous voiceover from the server) and calls PlaySound to play the new voiceover.

This scheme cannot work.
 
Реter Konow:
Well, TC wants a universal solution, where there's no need to integrate sound resources into Expert Advisor beforehand. He wants to design a system of interaction between the Expert Advisor and the server, in which the first creates a text file of words that NOW should be said by the user, and the server converts them to .wav and sends back to the Expert Advisor. Next, the Expert Advisor, unknowingly, writes the file in place of the previous file (with the previous voiceover from the server) and calls PlaySound to play the new voiceover.

Such a scheme cannot work.

I meant using ResourceCreate

Create a resource from the received data. And then play it with PlaySound. But I haven't found exactly such connection in examples (I'm not sure it will work). That's why I deleted previous message.

Документация по MQL5: Общие функции / ResourceCreate
Документация по MQL5: Общие функции / ResourceCreate
  • www.mql5.com
[in]  Относительный путь к файлу, содержащему данные для ресурса. Если путь начинается с обратной косой черты "\" (пишется "\\"), то файл ищется относительно папки Если второй вариант функции вызывается для...
 
Serhii Shevchuk:

I meant using ResourceCreate

Create a resource from the received data. And then play it with PlaySound. But I didn't find exactly such a link in the examples (not sure if it will work). So I deleted previous message.

Cool idea. Can try, although I'm not sure.)))
 
Serhii Shevchuk:

What exactly is your query not working? There are good examples in the documentation .

I don't have time to figure out the talker protocol right now, and it's useless.

Regarding your link - if you can not use WebSocket - better not to use, you will save a lot of time (if no experience with it). There are other options out there besides WebSocket.

here's what fails https://www.mql5.com/ru/forum/342293/page12#comment_16633648

File is created, but empty. Its name



is different from the file that is downloaded by curl command



It kind of hints that the code you wrote

//+------------------------------------------------------------------+
//|                                                   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);
     }
  }
//+------------------------------------------------------------------+


doesn't form WebRequest syntax correctly.

That is, it fails to make the WebRequest do what curl does

и снова dll и маркет
и снова dll и маркет
  • 2020.05.31
  • www.mql5.com
День добрый! Правило №1 dll на Маркете запрещен...
 
Nikolai Karetnikov:

here's what doesn't work https://www.mql5.com/ru/forum/342293/page12#comment_16633648

.....

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

 
If the sound file can be played back from the Files folder, where it is pre-recorded by the EA, then the solution to the problem will be realistic if the resulting sound file is coherent.
 
Nikolai Karetnikov:

here's what's not working https://www.mql5.com/ru/forum/342293/page12#comment_16633648

The file is created, but it is empty. Its name



is different from the file downloaded by the curl command



This kind of hints that the code you wrote


doesn't form WebRequest syntax correctly.

I.e. you can't make WebRequest do what curl does

and you won't :-)

why do you pass curl command options in HTTP headers?

well, at least read some books, look through some examples... otherwise, we'll all really write you an article

Reason: