{"id":466781,"date":"2025-07-11T15:00:37","date_gmt":"2025-07-11T15:00:37","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=466781"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=466781","title":{"rendered":"<span>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c API Speech2Text \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u043e\u0432<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0437\u0432\u043e\u043d\u043a\u0438 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u0432 \u043e\u0442\u0434\u0435\u043b\u0430 \u043f\u0440\u043e\u0434\u0430\u0436 \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u0438\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438, \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043d\u0435\u0434\u043e\u0447\u0451\u0442\u043e\u0432 \u0438 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u041d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c \u044d\u0442\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u043c\u0430\u043b\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0440\u0443\u0447\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b, \u0434\u043b\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0437\u0430\u0434\u0443\u043c\u0430\u043b\u0438 \u043f\u0440\u0438\u0432\u043b\u0435\u0447\u044c \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u0430. \u0418\u0434\u0435\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f: \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u0438 \u0437\u0432\u043e\u043d\u043a\u043e\u0432, \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0451\u043c \u0440\u0435\u0447\u044c (\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0432 \u0442\u0435\u043a\u0441\u0442), \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c LLM \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0442\u0435\u043a\u0441\u0442\u0430, \u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u0432\u044b\u0432\u043e\u0434\u0430\u043c\u0438, \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0439) \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0435 \u0432\u0440\u0443\u0447\u043d\u0443\u044e.<\/p>\n<p>\u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0430\u0443\u0434\u0438\u043e \u0440\u0435\u0448\u0438\u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0438\u0441 Speech2Text, \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f API \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f \u0438 \u043f\u043e\u043a\u0430\u0436\u0443 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. <\/p>\n<p>\u0412 \u0447\u0435\u0440\u043d\u043e\u0432\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0445\u0435\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u044b (\u043d\u0430\u0441 \u0441\u0435\u0439\u0447\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0441 \u043f\u043e\u0434\u043f\u0438\u0441\u044c\u044e <em>Speech2Text connector<\/em>):<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d14\/65c\/c95\/d1465cc9598d86af15af9aef01e843c0.png\" alt=\"\u041a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0430\u0443\u0434\u0438\u043e\u0437\u0430\u043f\u0438\u0441\u0435\u0439\" title=\"\u041a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0430\u0443\u0434\u0438\u043e\u0437\u0430\u043f\u0438\u0441\u0435\u0439\" width=\"851\" height=\"799\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/d14\/65c\/c95\/d1465cc9598d86af15af9aef01e843c0.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d14\/65c\/c95\/d1465cc9598d86af15af9aef01e843c0.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0430\u0443\u0434\u0438\u043e\u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/figcaption><\/div>\n<\/figure>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0431\u0443\u0434\u0435\u043c \u0432 C# <a href=\"http:\/\/ASP.NET\" rel=\"noopener noreferrer nofollow\">ASP.NET<\/a> Core \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 backend, \u0430 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (frontend). \u0428\u0442\u043e\u0448, \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c!<\/p>\n<p>\u0421\u043b\u0443\u0436\u0431\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c:<\/p>\n<pre><code class=\"cs\">\/\/\/ &lt;summary&gt; \/\/\/ Interface for Speech2Text interaction service. \/\/\/ &lt;\/summary&gt; public interface ISpeechToText {     \/\/\/ &lt;summary&gt;     \/\/\/ Creates a task on the Speech2Text server.     \/\/\/ &lt;\/summary&gt;     \/\/\/ &lt;param name=\"payload\"&gt;StreamContent containing the audio file.     \/\/\/ Will be disposed after use.&lt;\/param&gt;     \/\/\/ &lt;returns&gt;Task ID on the server or NULL in case of error.&lt;\/returns&gt;     Task&lt;string?&gt; SendTaskAsync(StreamContent payload);      \/\/\/ &lt;summary&gt;     \/\/\/ Checks the status of a task on the Speech2Text server.     \/\/\/ &lt;\/summary&gt;     \/\/\/ &lt;param name=\"taskId\"&gt;Required task ID received from the server when creating the task.&lt;\/param&gt;     \/\/\/ &lt;returns&gt;JobStatus.Decoding if the task is in progress;     \/\/\/ JobStatus.Decoded if the task was successfully processed;     \/\/\/ JobStatus.FailedToDecode if processing failed;     \/\/\/ null if the server response was not received or recognized, or in case of other errors.     \/\/\/ &lt;\/returns&gt;     Task&lt;JobStatus?&gt; GetTaskStatusAsync(string taskId);      \/\/\/ &lt;summary&gt;     \/\/\/ Gets the processing result of a task from the Speech2Text server.     \/\/\/ &lt;\/summary&gt;     \/\/\/ &lt;param name=\"taskId\"&gt;Required task ID received from the server when creating the task.&lt;\/param&gt;     \/\/\/ &lt;returns&gt;A string containing the processing result,     \/\/\/ or null in case of an error.&lt;\/returns&gt;     Task&lt;string?&gt; GetTaskResultAsync(string taskId); }<\/code><\/pre>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <em>\u0430\u0434\u0440\u0435\u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/em> \u0438 <em>\u043a\u043b\u044e\u0447 API<\/em>, \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0432 <code>appsettings.json<\/code> \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <a href=\"https:\/\/learn.microsoft.com\/en-us\/aspnet\/core\/fundamentals\/dependency-injection?view=aspnetcore-9.0\" rel=\"noopener noreferrer nofollow\">\u0438\u043d\u044a\u0435\u043a\u0446\u0438\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/a>, \u0432 \u0447\u0451\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 <a href=\"https:\/\/learn.microsoft.com\/en-us\/aspnet\/core\/fundamentals\/configuration\/options?view=aspnetcore-9.0\" rel=\"noopener noreferrer nofollow\">Options pattern<\/a>. \u041e\u043f\u0438\u0448\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a:<\/p>\n<pre><code class=\"cs\">public class SpeechToTextApiSettings {     public static string SectionName { get; } = \"Speech2textApi\";     public string BaseUrl { get; set; } = string.Empty;     public string TaskUrl { get; set; } = string.Empty;     public string ApiKey { get; set; } = string.Empty;      \/\/\/ &lt;summary&gt;     \/\/\/ HttpClient timeout in minutes     \/\/\/ &lt;\/summary&gt;     public int Timeout { get; set; } = 1; }<\/code><\/pre>\n<p>\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u0430\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432 <code>appsettings.json<\/code>(<strong>danger<\/strong>: \u043a\u043b\u044e\u0447 API \u0437\u0434\u0435\u0441\u044c \u043b\u0435\u0436\u0438\u0442 \u043d\u0430 \u0432\u0438\u0434\u0443, \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0441 \u044d\u0442\u0438\u043c \u0434\u0435\u043b\u0430\u0442\u044c):<\/p>\n<pre><code class=\"json\">\"Speech2textApi\": {   \"BaseUrl\": \"https:\/\/speech2text.ru\/api\/recognitions\",   \"TaskUrl\": \"https:\/\/speech2text.ru\/api\/recognitions\/task\/file\",   \"ApiKey\": \"MY-API-KEY-HERE\",   \"Timeout\": 1 }<\/code><\/pre>\n<p>\u0417\u0430\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043b\u0443\u0436\u0431\u044b <code>SpeechToText<\/code> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cs\">public class SpeechToText : ISpeechToText {     private readonly ILogger&lt;SpeechToText&gt; _logger;     private readonly HttpClient _httpClient;     private readonly SpeechToTextApiSettings _settings;      public SpeechToText(         HttpClient httpClient,         IOptions&lt;SpeechToTextApiSettings&gt; settings,         ILogger&lt;SpeechToText&gt; logger)     {         _logger = logger ?? throw new ArgumentNullException(nameof(logger));         _httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));         _settings = settings?.Value ?? throw new ArgumentNullException(nameof(settings));          if (string.IsNullOrWhiteSpace(_settings.BaseUrl))         {             throw new ArgumentNullException(nameof(_settings.BaseUrl),                  \"Base URL can't be empty\");         }         if (string.IsNullOrWhiteSpace(_settings.TaskUrl))         {             throw new ArgumentNullException(nameof(_settings.TaskUrl),                  \"Task URL can't be empty\");         }         _httpClient.BaseAddress = new Uri(_settings.BaseUrl);         _httpClient.Timeout = TimeSpan.FromMinutes(_settings.Timeout);         _httpClient.DefaultRequestHeaders.Authorization =              new(\"Bearer\", _settings.ApiKey);         _httpClient.DefaultRequestHeaders.Accept.Add(             new(\"application\/json\"));     }      public async Task&lt;string?&gt; SendTaskAsync(StreamContent payload)     {         throw new NotImplementedException();     }      public async Task&lt;JobStatus?&gt; GetTaskStatusAsync(string taskId)     {         throw new NotImplementedException();     }      public async Task&lt;string?&gt; GetTaskResultAsync(string taskId)     {         throw new NotImplementedException();     } }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c <code>HttpClient<\/code>. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c Bearer Authentication, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a (\u0441\u0442\u0440\u043e\u043a\u0430 28). \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0442\u0432\u0435\u0442 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0438 \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a (\u0441\u0442\u0440\u043e\u043a\u0430 30).<\/p>\n<p>\u0414\u043b\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <a href=\"https:\/\/github.com\/NLog\/NLog.Web\" rel=\"noopener noreferrer nofollow\">nLog<\/a>, \u0432\u043f\u0440\u043e\u0447\u0435\u043c, \u044d\u0442\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0443\u0431\u0435\u0440\u0443 \u0432\u0441\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u043b\u043e\u0433\u0433\u0435\u0440\u0430 \u0438\u0437 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0437\u0434\u0435\u0441\u044c \u043a\u043e\u0434\u0430, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0445\u043b\u0430\u043c\u043b\u044f\u0442\u044c \u0435\u0433\u043e.<\/p>\n<p>\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0444\u0430\u0439\u043b\u0430 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f POST \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c. \u0412 \u043e\u0442\u0432\u0435\u0442, \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u0435\u0440\u043d\u0451\u0442 <em>\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0437\u0430\u0434\u0430\u043d\u0438\u044f<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u2013 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443 \u043c\u044b \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u043d\u0430\u0439\u0434\u0451\u043c \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0438 \u0443\u0437\u043d\u0430\u0435\u043c, \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u043b\u0438 \u0442\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u0431\u0430\u0446\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438. \u041a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0443\u0437\u043d\u0430\u0435\u043c? \u0412\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e, \u043e\u0442\u0432\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c <em>\u0441\u0442\u0430\u0442\u0443\u0441<\/em>. \u0421\u0440\u0430\u0437\u0443 \u043e\u043f\u0438\u0448\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0441\u0442\u0430\u0442\u0443\u0441\u044b:<\/p>\n<pre><code class=\"cs\">\/\/\/ &lt;summary&gt; \/\/\/ Speech2Text server status codes. \/\/\/ &lt;\/summary&gt; public enum SpeechToTextStatuses {     \/\/\/ &lt;summary&gt;     \/\/\/ Content is received.     \/\/\/ &lt;\/summary&gt;     Received = 80,     \/\/\/ &lt;summary&gt;     \/\/\/ Task in progress.     \/\/\/ &lt;\/summary&gt;     Processing = 100,     \/\/\/ &lt;summary&gt;     \/\/\/ Completed successfully.     \/\/\/ &lt;\/summary&gt;     Completed = 200,     \/\/\/ &lt;summary&gt;     \/\/\/ Error while processing.     \/\/\/ &lt;\/summary&gt;     Error = 501 }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"cs\">public async Task&lt;string?&gt; SendTaskAsync(StreamContent payload) {     try     {         using var content = new MultipartFormDataContent();         content.Add(payload, \"file\", \"audio.mp3\");         content.Add(new StringContent(\"ru\"), \"lang\");         content.Add(new StringContent(\"2\"), \"speakers\");          using var response = await _httpClient.PostAsync(_settings.TaskUrl, content);         var responseText = await response.Content.ReadAsStringAsync();         if (!response.IsSuccessStatusCode)         {             return null;         }          using JsonDocument doc = JsonDocument.Parse(responseText);         var root = doc.RootElement;         if (root.TryGetProperty(\"id\", out var taskId)             &amp;&amp; taskId.GetString() is string taskIdValue             &amp;&amp; root.TryGetProperty(\"status\", out var taskStatus)             &amp;&amp; taskStatus.TryGetProperty(\"code\", out var taskCode)             &amp;&amp; taskCode.TryGetInt32(out int taskCodeValue))         {             if (taskCodeValue == (int)SpeechToTextStatuses.Received                 || taskCodeValue == (int)SpeechToTextStatuses.Processing)             {                 return taskIdValue;             }         }         return null;     }     catch (Exception ex)     {         return null;     }     finally     {         payload?.Dispose();     } }<\/code><\/pre>\n<p>\u0421\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f: <em>lang <\/em>\u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u044f\u0437\u044b\u043a\u0430 \u0438 <em>speakers <\/em>\u0434\u043b\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0433\u043e\u0432\u043e\u0440\u044f\u0449\u0438\u0445 (\u043b\u0438\u0431\u043e <em>max_speakers <\/em>\u0438 <em>min_speakers<\/em>, \u0435\u0441\u043b\u0438 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0434\u0438\u0430\u043b\u043e\u0433\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e). \u042d\u0442\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b, \u043d\u043e \u044f \u0438\u0445 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u044b\u0435. \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043b\u0443\u0447\u0448\u0435 \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c hardcoded values \u0438 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u043e \u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u043d\u0435\u043a\u0438\u0439 DTO, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430, \u043d\u043e \u0438 \u044d\u0442\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b.<\/p>\n<p>\u0415\u0449\u0451 \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <em>multi_channel<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b. \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 1, \u0435\u0441\u043b\u0438 \u0444\u0430\u0439\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0442\u0435\u0440\u0435\u043e\u0437\u0432\u0443\u043a, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0434\u0438\u043d \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043d\u0438\u043a \u0432 \u043e\u0434\u043d\u043e\u043c \u043a\u0430\u043d\u0430\u043b\u0435, \u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u2013 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c.<\/p>\n<p>\u042f \u043d\u0435 \u0441\u0442\u0430\u043b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u043e\u0442\u0432\u0435\u0442\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440. \u0412\u043e\u043e\u0431\u0449\u0435, \u043f\u043e\u043b\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"json\">{   \"id\": \"EUmFNuJzxuc0fAf8pjHaq29RDwF3Wuj0\",   \"created\": null,   \"options\": {     \"lang\": \"ru\",     \"speakers\": 2,     \"multi_channel\": null   },   \"file_meta\": {     \"mime\": \"audio\/mpeg\",     \"format\": \"MPEG Audio\",     \"audio_format\": \"MPEG Audio\",     \"channels\": 1,     \"duration\": \"00:01:14\"   },   \"resource\": {     \"type\": \"file\",     \"name\": \"audio.mp3\"   },   \"status\": {     \"code\": 100,     \"description\": \"\u0412 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u0438\u0435\"   },   \"payment\": {     \"source\": 1,     \"price\": 0   },   \"result\": null }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043a\u043e\u0434 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043d\u0430 200 \u2013 <em>\u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e<\/em> \u0438\u043b\u0438 501 \u2013 <em>\u043e\u0448\u0438\u0431\u043a\u0430 \u0442\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u0431\u0430\u0446\u0438\u0438<\/em>. \u041f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440, \u0432\u044b\u0437\u044b\u0432\u0430\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0438\u043c:<\/p>\n<pre><code class=\"cs\">public async Task&lt;JobStatus?&gt; GetTaskStatusAsync(string taskId) {     if (string.IsNullOrWhiteSpace(taskId))     {         return null;     }      try     {         string uriString = $\"{_settings.BaseUrl.TrimEnd('\/')}\/{taskId}\";         using var response = await _httpClient.GetAsync(uriString);         var responseText = await response.Content.ReadAsStringAsync();         if (!response.IsSuccessStatusCode)         {             return null;         }         using JsonDocument doc = JsonDocument.Parse(responseText);         var root = doc.RootElement;         if (root.TryGetProperty(\"status\", out var taskStatus)             &amp;&amp; taskStatus.TryGetProperty(\"code\", out var taskCode)             &amp;&amp; taskCode.TryGetInt32(out int taskCodeValue))         {             switch (taskCodeValue)             {                 case (int)SpeechToTextStatuses.Received:                 case (int)SpeechToTextStatuses.Processing:                     return JobStatus.Decoding;                 case (int)SpeechToTextStatuses.Completed:                     return JobStatus.Decoded;                 case (int)SpeechToTextStatuses.Error:                     return JobStatus.FailedToDecode;                 default:                     return JobStatus.FailedToDecode;             }         }         return null;     }     catch (Exception ex)     {         return null;     } }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0443\u0441 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0432 \u043d\u0430\u0448\u0435\u0439 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0411\u0414.<\/p>\n<p>\u0414\u043e\u0436\u0434\u0430\u0432\u0448\u0438\u0441\u044c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438, \u0437\u0430\u0431\u0435\u0440\u0451\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430:<\/p>\n<pre><code class=\"cs\">public async Task&lt;string?&gt; GetTaskResultAsync(string taskId) {     if (string.IsNullOrWhiteSpace(taskId))     {         return null;     }     try     {         string uriString = $\"{_settings.BaseUrl.TrimEnd('\/')}\/{taskId}\/result\/txt\";         using var response = await _httpClient.GetAsync(uriString);         var responseText = await response.Content.ReadAsStringAsync();         if (!response.IsSuccessStatusCode)         {             return null;         }         return string.IsNullOrWhiteSpace(responseText) ? null : responseText;     }     catch (Exception ex)     {         return null;     } }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u043b\u0430\u0434\u0448\u0438\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442 \u043f\u0443\u0442\u0438 URL (\u043a\u0441\u0442\u0430\u0442\u0438, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u044d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f?), \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b: <em>raw<\/em>, <em>txt<\/em>, <em>srt<\/em>, <em>vtt<\/em>, <em>json <\/em>\u0438 <em>xml<\/em>. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043a\u043e\u0434\u0430, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0432\u0438\u0434\u0435:<\/p>\n<blockquote>\n<p>\u0421\u043f\u0438\u043a\u0435\u0440 1:<\/p>\n<p>0:00:00 &#8212; \u0414\u0430, \u0410\u043b\u0435\u043a\u0441\u0435\u0439, \u0437\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435.<\/p>\n<p>\u0421\u043f\u0438\u043a\u0435\u0440 2:<\/p>\n<p>0:00:03 &#8212; \u042f \u0442\u0430\u043c \u0432\u0430\u043c \u043f\u0438\u0441\u044c\u043c\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043b, \u0432\u044b \u0432\u0438\u0434\u0435\u043b\u0438?<\/p>\n<p>\u0421\u043f\u0438\u043a\u0435\u0440 1:<\/p>\n<p>0:00:06 &#8212; &#8230;<\/p>\n<\/blockquote>\n<p>\u0412\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441\u043e \u0441\u043b\u0443\u0436\u0431\u043e\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0446\u0438\u043a\u043b\u0435, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0435\u043c\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 <a href=\"https:\/\/learn.microsoft.com\/en-us\/dotnet\/architecture\/microservices\/multi-container-microservice-net-applications\/background-tasks-with-ihostedservice\" rel=\"noopener noreferrer nofollow\">\u0444\u043e\u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438<\/a>. \u041c\u0435\u0436\u0434\u0443 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0446\u0438\u043a\u043b\u0430 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443, \u0447\u0442\u043e\u0431 \u043d\u0435 DoS\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438. \u0423\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u043e \u0438 \u0441\u043e\u043a\u0440\u0430\u0449\u0451\u043d\u043d\u043e \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a, \u043a\u0430\u043a \u0432 \u043a\u043e\u0434\u0435 \u043d\u0438\u0436\u0435. \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0438\u0437 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0411\u0414, \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044f\u0441\u044c \u043d\u0430 \u0438\u0445 \u0441\u0442\u0430\u0442\u0443\u0441\u0430\u0445, \u0434\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u0435\u043d\u044f\u0435\u043c \u0441\u0442\u0430\u0442\u0443\u0441\u044b, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044f \u043f\u0440\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u043f\u043e \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440\u0443 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438. <\/p>\n<pre><code class=\"cs\">public class ProcessingPipeline : BackgroundService {     \/\/ ...      protected override async Task ExecuteAsync(CancellationToken stoppingToken)     {         while (!stoppingToken.IsCancellationRequested)         {             try             {                 \/\/ enumerate file names                 foreach (var file in _filesProcessor.GetMp3Files())                 {                     \/\/ create jobs for newly added files                 }                  \/\/ enumerate executing jobs                 foreach (var job in await _jobsRepository.GetDecodingJobs())                 {                     if (await _speechToText.GetTaskStatusAsync(job.TaskId) is JobStatus status)                     {                         \/\/ change statuses of completed tasks                     }                 }                  \/\/ enumerate new jobs                 foreach (var job in await _jobsRepository.GetNewJobs())                 {                     \/\/ create server task and change job status                     if (_filesProcessor.ReadMp3FileToHttpStream(job.FileName)                          is StreamContent stream)                     {                         var result = await _speechToText.SendTaskAsync(stream);                         if (result is null)                         {                             job.Status = JobStatus.FailedToDecode;                         }                         else                         {                             job.Status = JobStatus.Decoding;                             job.TaskId = result;                         }                     }                 }             }             catch (OperationCanceledException)             {                 break;             }             catch (Exception ex)             {                 \/\/ _logger             }             await Task.Delay(_settings.Interval_ms, stoppingToken);         }     } }<\/code><\/pre>\n<p>\u042f \u043d\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e \u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u044f\u0445 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0411\u0414 \u0438 \u043f\u0440\u043e\u0447\u0435\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u0437\u0430 \u0440\u0430\u043c\u043a\u0430\u043c\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 (\u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0438 \u043e\u0431 \u044d\u0442\u043e\u043c, \u0435\u0441\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e).<\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a\u0438\u043c \u043d\u0435\u0445\u0438\u0442\u0440\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0430\u0443\u0434\u0438\u043e\u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u0421\u043e \u0441\u0432\u043e\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0445\u043e\u0447\u0443 \u043f\u043e\u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u0437\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f. \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c\u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438 (\u0430\u0443\u0434\u0438\u043e\u0437\u0430\u043f\u0438\u0441\u0438 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430, \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u0432, \u0430\u0431\u0431\u0440\u0435\u0432\u0438\u0430\u0442\u0443\u0440 \u0438 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0436\u0430\u0440\u0433\u043e\u043d\u0430), \u0438\u0437-\u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u0431\u0430\u0446\u0438\u044f \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u0430\u043a \u0445\u043e\u0440\u043e\u0448\u0430, \u043a\u0430\u043a \u0442\u043e\u0433\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b. \u041d\u043e, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u044d\u0442\u043e \u0440\u0435\u0448\u0438\u0442\u044c.<\/p>\n<p>\u0417\u0430\u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0439\u0442\u0435 \u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0438, \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435)<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/926918\/\"> https:\/\/habr.com\/ru\/articles\/926918\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0437\u0432\u043e\u043d\u043a\u0438 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u0432 \u043e\u0442\u0434\u0435\u043b\u0430 \u043f\u0440\u043e\u0434\u0430\u0436 \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u0438\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438, \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043d\u0435\u0434\u043e\u0447\u0451\u0442\u043e\u0432 \u0438 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u041d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c \u044d\u0442\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u043c\u0430\u043b\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0440\u0443\u0447\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b, \u0434\u043b\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0437\u0430\u0434\u0443\u043c\u0430\u043b\u0438 \u043f\u0440\u0438\u0432\u043b\u0435\u0447\u044c \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u0430. \u0418\u0434\u0435\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f: \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u0438 \u0437\u0432\u043e\u043d\u043a\u043e\u0432, \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0451\u043c \u0440\u0435\u0447\u044c (\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0432 \u0442\u0435\u043a\u0441\u0442), \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c LLM \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0442\u0435\u043a\u0441\u0442\u0430, \u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u0432\u044b\u0432\u043e\u0434\u0430\u043c\u0438, \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0439) \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0435 \u0432\u0440\u0443\u0447\u043d\u0443\u044e.<\/p>\n<p>\u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0430\u0443\u0434\u0438\u043e \u0440\u0435\u0448\u0438\u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0438\u0441 Speech2Text, \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f API \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f \u0438 \u043f\u043e\u043a\u0430\u0436\u0443 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. <\/p>\n<p>\u0412 \u0447\u0435\u0440\u043d\u043e\u0432\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0445\u0435\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u044b (\u043d\u0430\u0441 \u0441\u0435\u0439\u0447\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0441 \u043f\u043e\u0434\u043f\u0438\u0441\u044c\u044e <em>Speech2Text connector<\/em>):<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0430\u0443\u0434\u0438\u043e\u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/figcaption><\/div>\n<\/figure>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0431\u0443\u0434\u0435\u043c \u0432 C# <a href=\"http:\/\/ASP.NET\" rel=\"noopener noreferrer nofollow\">ASP.NET<\/a> Core \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 backend, \u0430 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (frontend). \u0428\u0442\u043e\u0448, \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c!<\/p>\n<p>\u0421\u043b\u0443\u0436\u0431\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c:<\/p>\n<pre><code class=\"cs\">\/\/\/ &lt;summary&gt; \/\/\/ Interface for Speech2Text interaction service. \/\/\/ &lt;\/summary&gt; public interface ISpeechToText {     \/\/\/ &lt;summary&gt;     \/\/\/ Creates a task on the Speech2Text server.     \/\/\/ &lt;\/summary&gt;     \/\/\/ &lt;param name=\"payload\"&gt;StreamContent containing the audio file.     \/\/\/ Will be disposed after use.&lt;\/param&gt;     \/\/\/ &lt;returns&gt;Task ID on the server or NULL in case of error.&lt;\/returns&gt;     Task&lt;string?&gt; SendTaskAsync(StreamContent payload);      \/\/\/ &lt;summary&gt;     \/\/\/ Checks the status of a task on the Speech2Text server.     \/\/\/ &lt;\/summary&gt;     \/\/\/ &lt;param name=\"taskId\"&gt;Required task ID received from the server when creating the task.&lt;\/param&gt;     \/\/\/ &lt;returns&gt;JobStatus.Decoding if the task is in progress;     \/\/\/ JobStatus.Decoded if the task was successfully processed;     \/\/\/ JobStatus.FailedToDecode if processing failed;     \/\/\/ null if the server response was not received or recognized, or in case of other errors.     \/\/\/ &lt;\/returns&gt;     Task&lt;JobStatus?&gt; GetTaskStatusAsync(string taskId);      \/\/\/ &lt;summary&gt;     \/\/\/ Gets the processing result of a task from the Speech2Text server.     \/\/\/ &lt;\/summary&gt;     \/\/\/ &lt;param name=\"taskId\"&gt;Required task ID received from the server when creating the task.&lt;\/param&gt;     \/\/\/ &lt;returns&gt;A string containing the processing result,     \/\/\/ or null in case of an error.&lt;\/returns&gt;     Task&lt;string?&gt; GetTaskResultAsync(string taskId); }<\/code><\/pre>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <em>\u0430\u0434\u0440\u0435\u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/em> \u0438 <em>\u043a\u043b\u044e\u0447 API<\/em>, \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0432 <code>appsettings.json<\/code> \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <a href=\"https:\/\/learn.microsoft.com\/en-us\/aspnet\/core\/fundamentals\/dependency-injection?view=aspnetcore-9.0\" rel=\"noopener noreferrer nofollow\">\u0438\u043d\u044a\u0435\u043a\u0446\u0438\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/a>, \u0432 \u0447\u0451\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 <a href=\"https:\/\/learn.microsoft.com\/en-us\/aspnet\/core\/fundamentals\/configuration\/options?view=aspnetcore-9.0\" rel=\"noopener noreferrer nofollow\">Options pattern<\/a>. \u041e\u043f\u0438\u0448\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a:<\/p>\n<pre><code class=\"cs\">public class SpeechToTextApiSettings {     public static string SectionName { get; } = \"Speech2textApi\";     public string BaseUrl { get; set; } = string.Empty;     public string TaskUrl { get; set; } = string.Empty;     public string ApiKey { get; set; } = string.Empty;      \/\/\/ &lt;summary&gt;     \/\/\/ HttpClient timeout in minutes     \/\/\/ &lt;\/summary&gt;     public int Timeout { get; set; } = 1; }<\/code><\/pre>\n<p>\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u0430\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432 <code>appsettings.json<\/code>(<strong>danger<\/strong>: \u043a\u043b\u044e\u0447 API \u0437\u0434\u0435\u0441\u044c \u043b\u0435\u0436\u0438\u0442 \u043d\u0430 \u0432\u0438\u0434\u0443, \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0441 \u044d\u0442\u0438\u043c \u0434\u0435\u043b\u0430\u0442\u044c):<\/p>\n<pre><code class=\"json\">\"Speech2textApi\": {   \"BaseUrl\": \"https:\/\/speech2text.ru\/api\/recognitions\",   \"TaskUrl\": \"https:\/\/speech2text.ru\/api\/recognitions\/task\/file\",   \"ApiKey\": \"MY-API-KEY-HERE\",   \"Timeout\": 1 }<\/code><\/pre>\n<p>\u0417\u0430\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043b\u0443\u0436\u0431\u044b <code>SpeechToText<\/code> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cs\">public class SpeechToText : ISpeechToText {     private readonly ILogger&lt;SpeechToText&gt; _logger;     private readonly HttpClient _httpClient;     private readonly SpeechToTextApiSettings _settings;      public SpeechToText(         HttpClient httpClient,         IOptions&lt;SpeechToTextApiSettings&gt; settings,         ILogger&lt;SpeechToText&gt; logger)     {         _logger = logger ?? throw new ArgumentNullException(nameof(logger));         _httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));         _settings = settings?.Value ?? throw new ArgumentNullException(nameof(settings));          if (string.IsNullOrWhiteSpace(_settings.BaseUrl))         {             throw new ArgumentNullException(nameof(_settings.BaseUrl),                  \"Base URL can't be empty\");         }         if (string.IsNullOrWhiteSpace(_settings.TaskUrl))         {             throw new ArgumentNullException(nameof(_settings.TaskUrl),                  \"Task URL can't be empty\");         }         _httpClient.BaseAddress = new Uri(_settings.BaseUrl);         _httpClient.Timeout = TimeSpan.FromMinutes(_settings.Timeout);         _httpClient.DefaultRequestHeaders.Authorization =              new(\"Bearer\", _settings.ApiKey);         _httpClient.DefaultRequestHeaders.Accept.Add(             new(\"application\/json\"));     }      public async Task&lt;string?&gt; SendTaskAsync(StreamContent payload)     {         throw new NotImplementedException();     }      public async Task&lt;JobStatus?&gt; GetTaskStatusAsync(string taskId)     {         throw new NotImplementedException();     }      public async Task&lt;string?&gt; GetTaskResultAsync(string taskId)     {         throw new NotImplementedException();     } }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c <code>HttpClient<\/code>. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c Bearer Authentication, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a (\u0441\u0442\u0440\u043e\u043a\u0430 28). \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0442\u0432\u0435\u0442 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0438 \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a (\u0441\u0442\u0440\u043e\u043a\u0430 30).<\/p>\n<p>\u0414\u043b\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <a href=\"https:\/\/github.com\/NLog\/NLog.Web\" rel=\"noopener noreferrer nofollow\">nLog<\/a>, \u0432\u043f\u0440\u043e\u0447\u0435\u043c, \u044d\u0442\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0443\u0431\u0435\u0440\u0443 \u0432\u0441\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u043b\u043e\u0433\u0433\u0435\u0440\u0430 \u0438\u0437 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0437\u0434\u0435\u0441\u044c \u043a\u043e\u0434\u0430, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0445\u043b\u0430\u043c\u043b\u044f\u0442\u044c \u0435\u0433\u043e.<\/p>\n<p>\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0444\u0430\u0439\u043b\u0430 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f POST \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c. \u0412 \u043e\u0442\u0432\u0435\u0442, \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u0435\u0440\u043d\u0451\u0442 <em>\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0437\u0430\u0434\u0430\u043d\u0438\u044f<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u2013 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443 \u043c\u044b \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u043d\u0430\u0439\u0434\u0451\u043c \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0438 \u0443\u0437\u043d\u0430\u0435\u043c, \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u043b\u0438 \u0442\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u0431\u0430\u0446\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438. \u041a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0443\u0437\u043d\u0430\u0435\u043c? \u0412\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e, \u043e\u0442\u0432\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c <em>\u0441\u0442\u0430\u0442\u0443\u0441<\/em>. \u0421\u0440\u0430\u0437\u0443 \u043e\u043f\u0438\u0448\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0441\u0442\u0430\u0442\u0443\u0441\u044b:<\/p>\n<pre><code class=\"cs\">\/\/\/ &lt;summary&gt; \/\/\/ Speech2Text server status codes. \/\/\/ &lt;\/summary&gt; public enum SpeechToTextStatuses {     \/\/\/ &lt;summary&gt;     \/\/\/ Content is received.     \/\/\/ &lt;\/summary&gt;     Received = 80,     \/\/\/ &lt;summary&gt;     \/\/\/ Task in progress.     \/\/\/ &lt;\/summary&gt;     Processing = 100,     \/\/\/ &lt;summary&gt;     \/\/\/ Completed successfully.     \/\/\/ &lt;\/summary&gt;     Completed = 200,     \/\/\/ &lt;summary&gt;     \/\/\/ Error while processing.     \/\/\/ &lt;\/summary&gt;     Error = 501 }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"cs\">public async Task&lt;string?&gt; SendTaskAsync(StreamContent payload) {     try     {         using var content = new MultipartFormDataContent();         content.Add(payload, \"file\", \"audio.mp3\");         content.Add(new StringContent(\"ru\"), \"lang\");         content.Add(new StringContent(\"2\"), \"speakers\");          using var response = await _httpClient.PostAsync(_settings.TaskUrl, content);         var responseText = await response.Content.ReadAsStringAsync();         if (!response.IsSuccessStatusCode)         {             return null;         }          using JsonDocument doc = JsonDocument.Parse(responseText);         var root = doc.RootElement;         if (root.TryGetProperty(\"id\", out var taskId)             &amp;&amp; taskId.GetString() is string taskIdValue             &amp;&amp; root.TryGetProperty(\"status\", out var taskStatus)             &amp;&amp; taskStatus.TryGetProperty(\"code\", out var taskCode)             &amp;&amp; taskCode.TryGetInt32(out int taskCodeValue))         {             if (taskCodeValue == (int)SpeechToTextStatuses.Received                 || taskCodeValue == (int)SpeechToTextStatuses.Processing)             {                 return taskIdValue;             }         }         return null;     }     catch (Exception ex)     {         return null;     }     finally     {         payload?.Dispose();     } }<\/code><\/pre>\n<p>\u0421\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f: <em>lang <\/em>\u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u044f\u0437\u044b\u043a\u0430 \u0438 <em>speakers <\/em>\u0434\u043b\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0433\u043e\u0432\u043e\u0440\u044f\u0449\u0438\u0445 (\u043b\u0438\u0431\u043e <em>max_speakers <\/em>\u0438 <em>min_speakers<\/em>, \u0435\u0441\u043b\u0438 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0434\u0438\u0430\u043b\u043e\u0433\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e). \u042d\u0442\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b, \u043d\u043e \u044f \u0438\u0445 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u044b\u0435. \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043b\u0443\u0447\u0448\u0435 \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c hardcoded values \u0438 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u043e \u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u043d\u0435\u043a\u0438\u0439 DTO, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430, \u043d\u043e \u0438 \u044d\u0442\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b.<\/p>\n<p>\u0415\u0449\u0451 \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <em>multi_channel<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b. \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 1, \u0435\u0441\u043b\u0438 \u0444\u0430\u0439\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0442\u0435\u0440\u0435\u043e\u0437\u0432\u0443\u043a, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0434\u0438\u043d \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043d\u0438\u043a \u0432 \u043e\u0434\u043d\u043e\u043c \u043a\u0430\u043d\u0430\u043b\u0435, \u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u2013 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c.<\/p>\n<p>\u042f \u043d\u0435 \u0441\u0442\u0430\u043b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u043e\u0442\u0432\u0435\u0442\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440. \u0412\u043e\u043e\u0431\u0449\u0435, \u043f\u043e\u043b\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"json\">{   \"id\": \"EUmFNuJzxuc0fAf8pjHaq29RDwF3Wuj0\",   \"created\": null,   \"options\": {     \"lang\": \"ru\",     \"speakers\": 2,     \"multi_channel\": null   },   \"file_meta\": {     \"mime\": \"audio\/mpeg\",     \"format\": \"MPEG Audio\",     \"audio_format\": \"MPEG Audio\",     \"channels\": 1,     \"duration\": \"00:01:14\"   },   \"resource\": {     \"type\": \"file\",     \"name\": \"audio.mp3\"   },   \"status\": {     \"code\": 100,     \"description\": \"\u0412 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u0438\u0435\"   },   \"payment\": {     \"source\": 1,     \"price\": 0   },   \"result\": null }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043a\u043e\u0434 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043d\u0430 200 \u2013 <em>\u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e<\/em> \u0438\u043b\u0438 501 \u2013 <em>\u043e\u0448\u0438\u0431\u043a\u0430 \u0442\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u0431\u0430\u0446\u0438\u0438<\/em>. \u041f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440, \u0432\u044b\u0437\u044b\u0432\u0430\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0438\u043c:<\/p>\n<pre><code class=\"cs\">public async Task&lt;JobStatus?&gt; GetTaskStatusAsync(string taskId) {     if (string.IsNullOrWhiteSpace(taskId))     {         return null;     }      try     {         string uriString = $\"{_settings.BaseUrl.TrimEnd('\/')}\/{taskId}\";         using var response = await _httpClient.GetAsync(uriString);         var responseText = await response.Content.ReadAsStringAsync();         if (!response.IsSuccessStatusCode)         {             return null;         }         using JsonDocument doc = JsonDocument.Parse(responseText);         var root = doc.RootElement;         if (root.TryGetProperty(\"status\", out var taskStatus)             &amp;&amp;<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-466781","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/466781","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=466781"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/466781\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=466781"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=466781"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=466781"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}