<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Giulio Fronterotta</title>
    <description>The latest articles on DEV Community by Giulio Fronterotta (@frontegi).</description>
    <link>https://dev.to/frontegi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F730614%2Fc99bb180-fcf2-46ae-97bd-f4f07723f54d.jpeg</url>
      <title>DEV Community: Giulio Fronterotta</title>
      <link>https://dev.to/frontegi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/frontegi"/>
    <language>en</language>
    <item>
      <title>Background Speech-To-Text with Azure, on a Windows Machine</title>
      <dc:creator>Giulio Fronterotta</dc:creator>
      <pubDate>Tue, 19 Oct 2021 23:17:47 +0000</pubDate>
      <link>https://dev.to/frontegi/background-speech-to-text-with-azure-on-a-windows-machine-1jbf</link>
      <guid>https://dev.to/frontegi/background-speech-to-text-with-azure-on-a-windows-machine-1jbf</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjozupds69aqrntbkrtd4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjozupds69aqrntbkrtd4.png" alt="Basic STT Architecture" width="756" height="314"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The source code of solution presented in this article,is available &lt;a href="https://github.com/frontegi/AzureSTTService" rel="noopener noreferrer"&gt;at&lt;br&gt;
my GitHub repo page&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A portable release, no .Net Core installation required, can be obtained in the &lt;a href="https://github.com/frontegi/AzureSTTService/releases" rel="noopener noreferrer"&gt;GitHub Release page&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I've always been really passionate about digital audio processing. In the last decade, the cloud power has spinned incredible advancement in those techniques. A really interesting area is related to the tools each &lt;strong&gt;CSP (Cloud Service Provider)&lt;/strong&gt; is providing to empower developers in creating interesting use cases. &lt;br&gt;
The &lt;strong&gt;Speech-To-Text&lt;/strong&gt; and &lt;strong&gt;Text-To-Speech&lt;/strong&gt; are now widely used service, due to the network speed that is no longer a bottleneck, in most of the cases. &lt;/p&gt;

&lt;p&gt;I had recently faced a challenge in creating a DEMO where an  hardware device, triggered by a command, posted a wave audio file recording to a folder on a server.&lt;/p&gt;

&lt;p&gt;Then the desiderata was to have the transcript of the recorded audio along with the original recording.&lt;/p&gt;

&lt;p&gt;This project aimed to create a simple Windows Background service in C# code, to perform subsequent Speech-To-Text (STT) process using Azure cloud.&lt;/p&gt;

&lt;p&gt;The first challenge was that the file format  could be a Wave PCM with 4 channels, recorded at 48 kHz. Not really a friendly format digested by cloud STT (Speech-To-Text). &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjdq2w48u1omph9upziyv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjdq2w48u1omph9upziyv.png" alt="4 channels audio in Resonic Player" width="741" height="369"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The second challenge was to have this service run autonomously on a windows server.&lt;/p&gt;

&lt;p&gt;The Speech API I'm using is the &lt;strong&gt;synchronous&lt;/strong&gt; one, so this project fit great when you don't want to setup complex architecture on Azure and you prefer the processing on the VM. Another point is when you want to transcript short duration file. The transcription, in fact stop when a long pause is detected in the original file. &lt;/p&gt;

&lt;p&gt;To process long file and if you prefer a more "Batch" solution take a look &lt;a href="https://techcommunity.microsoft.com/t5/azure-ai/azure-speech-and-batch-ingestion/ba-p/2222539" rel="noopener noreferrer"&gt;to this great solution&lt;/a&gt; by &lt;a href="https://techcommunity.microsoft.com/t5/user/viewprofilepage/user-id/210559" rel="noopener noreferrer"&gt;PanosPeriorellis&lt;/a&gt; .&lt;br&gt;
Check out the dedicated &lt;a href="https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/batch-transcription" rel="noopener noreferrer"&gt;documentation regarding Batch Transcription API&lt;/a&gt; for further info.&lt;/p&gt;

&lt;p&gt;So, in brief, the required workflow was:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run in background on a windows machine, even after a reboot&lt;/li&gt;
&lt;li&gt;polling on a specific folder, waiting for new wave files&lt;/li&gt;
&lt;li&gt;when a new file is detected, verify the format (channels, frequency, bit depth)&lt;/li&gt;
&lt;li&gt;If necessary, convert it to a Cloud friendly format (1 or 2 audio channels, 16 bit depth, 16 Khz frequency)&lt;/li&gt;
&lt;li&gt;Submit the file to Cloud STT service&lt;/li&gt;
&lt;li&gt;Move the original input file from &lt;strong&gt;Input Folder&lt;/strong&gt; to a &lt;strong&gt;"Processed"&lt;/strong&gt; folder, adding timestamp to the filename&lt;/li&gt;
&lt;li&gt;Save the audio transcript from cloud to a recognizable .txt file in the same &lt;strong&gt;"Processed&lt;/strong&gt;" folder of the windows machine
&lt;/li&gt;
&lt;li&gt;To show the last transcription done, write a fixed txt file with the last result (For most usage, this is useless)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I was used to write Windows Background Service in the past, in the banking industry, to process text records file. &lt;/p&gt;

&lt;p&gt;So I approached the same way, but using a more modern approach with .Net Core 5.0 . I started reading the documentation about how to develop a windows background service and the I started coding. &lt;/p&gt;

&lt;p&gt;The first cool thing about the new &lt;a href="https://docs.microsoft.com/it-it/dotnet/core/extensions/windows-service" rel="noopener noreferrer"&gt;BackgroundService .Net Core&lt;/a&gt; implementation, is that you can easily run the code within Visual Studio without issues. &lt;/p&gt;

&lt;p&gt;The built package can then be run from command line or installed as a service. &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjob6337289tqaktxz509.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjob6337289tqaktxz509.png" alt="The Service inside the console" width="800" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the past was a nightmare to debug windows services. You were required to write the business logic in DLLs, test the service in exe wrapper, or  debug attaching to an running service. Now things are really better.&lt;/p&gt;

&lt;p&gt;Regarding the &lt;strong&gt;Visual Studio&lt;/strong&gt; solution, when you want to package the binaries, you can use the &lt;strong&gt;Project -&amp;gt; (right-mouse click) -&amp;gt; Publish -&amp;gt; Publish to Folder&lt;/strong&gt; feature, to create a portable version. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz4tzfghg2b93fnsaqemz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz4tzfghg2b93fnsaqemz.png" alt="Visual Studio" width="599" height="464"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fds7sgkt511m0ztjnbmvs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fds7sgkt511m0ztjnbmvs.png" alt="Publish Wizard" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can create a self-contained exe package, with all the required .Net core file embedded (portable). You can run this service even on a windows machine without .Net Core framework (obviously, the file has a huge size). &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fne6r2jhi4slt4drbh116.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fne6r2jhi4slt4drbh116.png" alt="The Portable Giant file" width="800" height="323"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want a lighter version and .net Core framework is installed on target machine, use the classic Binary Release created during compilation.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc8vcwacdekda99n7su50.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc8vcwacdekda99n7su50.png" alt="Light Build" width="800" height="278"&gt;&lt;/a&gt;&lt;br&gt;
We are talking about a 126 MByte exe vs a 0,12 MBytes file ...&lt;/p&gt;
&lt;h1&gt;
  
  
  Libraries used recap
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;.Net core 5.0&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As mentioned, this project has been built with .Net Core 5.0 framework. &lt;br&gt;
Please refer to (&lt;a href="https://docs.microsoft.com/en-us/dotnet/core/extensions/windows-service" rel="noopener noreferrer"&gt;https://docs.microsoft.com/en-us/dotnet/core/extensions/windows-service&lt;/a&gt;) for information on developing .Net Core 5.0 Background services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Microsoft Cognitive Services Speech SDK&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To interact with cloud Speech services, this software use the c# Speech SDK library from Microsoft.&lt;br&gt;
For further info and documentation,go to (&lt;a href="https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/speech-sdk" rel="noopener noreferrer"&gt;https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/speech-sdk&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NAudio&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Due to a specific requirements, processing and transforming wave files BEFORE the submission to the Azure Cloud Speech Services, the service make use of the library NAudio, that sadly requires the service to be built/targeted on Windows platform only. &lt;br&gt;
(&lt;a href="https://github.com/naudio/NAudio" rel="noopener noreferrer"&gt;https://github.com/naudio/NAudio&lt;/a&gt;)&lt;/p&gt;
&lt;h1&gt;
  
  
  Folders structure
&lt;/h1&gt;

&lt;p&gt;The below structure is only an example. Each folder can be in a different path in your machine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;root 
│   
└───inputFolder 
[The folder where you insert wave files to be elaborated]

└───channelSplitFolder 
[A temporary working folder. When a wave file has more than 2 channels or it has been recorded at a frequency higher than 16 Khz, here you will find the downsampled version and individual channels (i.e. a 4 channels wave file will be splitted in 4 different mono file)]

└───errorFolder
[if something unexpected happens during the process, the wave file is moved from inputFolder to errorFolder, to avoid reprocessing of the file]

└───outputFolder
[at the end of processing wave file is moved from the input folder in the output folder renamed with a timestamp. A corresponding txt file is created along the wave file with the transcription]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Code Highlights
&lt;/h1&gt;

&lt;p&gt;I use the NAudio library to open incoming file and detect if it contains more than 2 channels&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var reader = new WaveFileReader(sourcePath);
 if (reader.WaveFormat.Channels &amp;gt; 2) then ... 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If this is the case, I used this routine to write each channel in a separate, mono, file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var writers = new WaveFileWriter[reader.WaveFormat.Channels];
for (int n = 0; n &amp;lt; writers.Length; n++)
{
    var format = new WaveFormat(reader.WaveFormat.SampleRate, 16, 1);
    string combinedPath = Path.Combine(channelSplitFolder, string.Format($"channel-{n + 1}.wav"));
    writers[n] = new WaveFileWriter(combinedPath, format);
}

float[] buffer;
while ((buffer = reader.ReadNextSampleFrame())?.Length &amp;gt; 0)
{
    for (int i = 0; i &amp;lt; buffer.Length; i++)
    {
        // write one sample for each channel (i is the channelNumber)
        writers[i].WriteSample(buffer[i]);
    }
}

for (int n = 0; n &amp;lt; writers.Length; n++)
{
    writers[n].Dispose();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the same approach to verify frequencies higher than 16 kHz and, in case, downsample to 16 kHz:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;reader.WaveFormat.SampleRate &amp;gt; 16000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, with the help of stackoverflow, I wrote this routine&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; string convertedStreamFilename = Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file) + "-16KHz.wav");

 using (var wavConverterReader = new WaveFileReader(file))
 {
     var newFormat = new WaveFormat(16000, 16, 1);

     using (var conversionStream = new WaveFormatConversionStream(newFormat, wavConverterReader))
     {
         //Replace original file
         WaveFileWriter.CreateWaveFile(convertedStreamFilename, conversionStream);
     }
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And this block is the core of the SDK call to Speech Services&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Perform STT
using AudioConfig audioConfig = AudioConfig.FromWavFileInput(STTSourcePath);

speechConfig.SpeechRecognitionLanguage = sourceLanguage;
speechConfig.EnableAudioLogging();
speechConfig.SetProperty(PropertyId.Conversation_Initial_Silence_Timeout, "5");

ResultReason STTResult;
using (var recognizer = new SpeechRecognizer(speechConfig, audioConfig))
{
    _logger.LogInformation(String.Format("Sending file {0} to Azure STT Service", Path.GetFileName(STTSourcePath)));
    //Do the real STT Job on cloud
    var result = await recognizer.RecognizeOnceAsync();
    STTResult = result.Reason;
    if (result.Reason == ResultReason.RecognizedSpeech) {                    
        _logger.LogInformation("Moving file from {0}\r\nto {1}", sourcePath, destWavPath);
        _logger.LogInformation($"RECOGNIZED STT: Text={result.Text}");
        //Dumping Json Response file to History Directory
        await File.WriteAllTextAsync(destSttTxtPath, result.Text);
        //Dumping Json Response file to fixed destination directory (This one is not really required, but introduced for a specific need)
        await File.WriteAllTextAsync(singleTxtTranslationTargetFile, result.Text); 
    }
    //Avoid File locking errors
    recognizer.Dispose();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Please note that you can set the source language with &lt;strong&gt;SpeechRecognitionLanguage&lt;/strong&gt; property or set the Initial Timeout inside the audio file with the &lt;strong&gt;Conversation_Initial_Silence_Timeout&lt;/strong&gt; setting&lt;/p&gt;

&lt;h1&gt;
  
  
  How to Create an Azure Speech service resource
&lt;/h1&gt;

&lt;p&gt;Azure gives you 5 hours of free Speech-To-Text each month.&lt;br&gt;
To create your Speech Service resource, follow these steps (Prerequisite, you have at least a trial Azure Subscription):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Visit this URL, &lt;a href="https://portal.azure.com/#blade/HubsExtension/BrowseResource/resourceType/Microsoft.CognitiveServices%2Faccounts" rel="noopener noreferrer"&gt;https://portal.azure.com/#blade/HubsExtension/BrowseResource/resourceType/Microsoft.CognitiveServices%2Faccounts&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  Press the button "Add Speech Service"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs3jzz5i6z5ppm6xsu1k7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs3jzz5i6z5ppm6xsu1k7.png" alt="Add Speech Service" width="476" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Fill the values as in the below example. &lt;strong&gt;Name&lt;/strong&gt; is whatever you want. &lt;strong&gt;Subscription&lt;/strong&gt; is your Azure Subscription. &lt;strong&gt;Location&lt;/strong&gt; is the Azure region where your service will be hosted. &lt;strong&gt;Pricing Tier&lt;/strong&gt; can be F0, the free one, but you can create only one free resource for each subscription. S0 is the paid one, but you have always 5 free hour before paying. As &lt;strong&gt;Resource Group&lt;/strong&gt; select an existing one or create a fresh resource group right here.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7lbb1fg6as3kfheqvvf7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7lbb1fg6as3kfheqvvf7.png" alt="Add Speech Service" width="337" height="414"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Press "Create"&lt;/li&gt;
&lt;li&gt;  At the end of deployment, press “Go To Resource”, or open the newly created resource from the specific Resource Group&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdl6sqhhk1rqsiywdv8ay.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdl6sqhhk1rqsiywdv8ay.png" alt="Add Speech Service" width="582" height="363"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Read the Key to be able to use the service. Remember, this is the setting to be placed in the Application Settings file, BEFORE starting the service&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F86p3uibe9tf4amhuy5jm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F86p3uibe9tf4amhuy5jm.png" alt="Add Speech Service" width="800" height="362"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;If you better prefer, take a look at the official Microsoft Guide to create the Speech service (&lt;a href="https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/overview#create-the-azure-resource" rel="noopener noreferrer"&gt;https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/overview#create-the-azure-resource&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Once you have created your speech resource, you can play with the Speech Studio. Speech Studio is a great Web GUI where you can experiment with all Speech related cloud service.&lt;br&gt;
Speech Studio can be reached at (&lt;a href="https://speech.microsoft.com/" rel="noopener noreferrer"&gt;https://speech.microsoft.com/&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdme5yg6n7c7nq5j6zose.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdme5yg6n7c7nq5j6zose.png" alt="Speech Studio screenshot" width="800" height="615"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For an overview of speech studio, visit (&lt;a href="https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/speech-studio-overview" rel="noopener noreferrer"&gt;https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/speech-studio-overview&lt;/a&gt;)&lt;/p&gt;
&lt;h1&gt;
  
  
  Application Settings
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Before starting the service&lt;/strong&gt;, please change the application settings, at your convenience.&lt;br&gt;
Open appsettings.json with yor favourite editor.&lt;/p&gt;

&lt;p&gt;Keys description:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;AzureSTTService - Key&lt;/strong&gt; : Place your speech service secret key - See the &lt;em&gt;"How To Create Azure Speech service resource section"&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;AzureSTTService - Region&lt;/strong&gt; : Set the region where you provisioned the service (i.e.= westeurope)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;AzureSTTService - SourceLanguage&lt;/strong&gt; : Set the language to transcribe from. For a complete list goto column &lt;strong&gt;Locale (BCP-47)&lt;/strong&gt; at (&lt;a href="https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/language-support#speech-to-text" rel="noopener noreferrer"&gt;https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/language-support#speech-to-text&lt;/a&gt;) &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;DO NOT FORGET THE DOUBLE SLASHES IN THE PATHS&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Folders - InputFolder&lt;/strong&gt; : The folder where you insert wave files to be elaborated (i.e c:\stt\inputFolder)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Folders - OutputFolder&lt;/strong&gt; : Where you will find original file wav and txt transcription renamed with a timestamp&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdi15pod1rz9nle67c5xj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdi15pod1rz9nle67c5xj.png" alt="Output Folder files exmaple" width="643" height="442"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Folders - ErrorFolder&lt;/strong&gt; : If any error occur, file are moved here from the input folder&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Folders - ChannelsSplitFolder&lt;/strong&gt; : Post-Processed audio file (stereo or more channels, frequencies higher than 16 Khz) are placed here for convenience. Directory is cleaned for each transcription.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo1bj5xjo2sz7lcz66qwu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo1bj5xjo2sz7lcz66qwu.png" alt="files splitted and formatted inside the ChannelSplitFolder" width="648" height="308"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Folders - SingleTxtTranslationTargetFile&lt;/strong&gt; : A path to a specific txt file. It will always contain the latest transcription and will be overwritten by each processing iteration (i.e "c:\stt\outputfolder\last_transcription.txt")&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  Installation
&lt;/h1&gt;

&lt;p&gt;Once the project is built (or published to a folder), copy the binaries output and place them in a directory of your choice (ex: "c:\Program Files\STTCloudservice")&lt;/p&gt;

&lt;p&gt;To install it as a windows service&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;open a powershell as administrator &lt;/li&gt;
&lt;li&gt;run the following command, replace &lt;strong&gt;binpath&lt;/strong&gt; with your binaries folder
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sc.exe create &lt;span class="s2"&gt;"Azure Cloud STT Service"&lt;/span&gt; &lt;span class="nv"&gt;binpath&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;C:&lt;span class="se"&gt;\s&lt;/span&gt;tt-service&lt;span class="se"&gt;\A&lt;/span&gt;zureCloudSTTService.exe
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;After installation, the service Startup mode is Manual. If you want you can change it to Automatic, so the software can start autonomously at each reboot.&lt;br&gt;
You can do it from the Windows Services GUI, or via command line&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7s8b42519t5rtqm4axp2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7s8b42519t5rtqm4axp2.png" alt="The service consolle" width="500" height="584"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sc.exe config &lt;span class="s2"&gt;"Azure Cloud STT Service"&lt;/span&gt; &lt;span class="nv"&gt;start&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;auto
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Interact with the windows service
&lt;/h2&gt;

&lt;p&gt;You can start and stop service from the Services Consoles (WIN+R then launch "services.msc")&lt;/p&gt;

&lt;p&gt;Alternatively, from the command line&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start Service
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sc.exe start &lt;span class="s2"&gt;"Azure Cloud STT Service"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Stop Service
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sc.exe stop &lt;span class="s2"&gt;"Azure Cloud STT Service"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Uninstall
&lt;/h2&gt;

&lt;p&gt;Before uninstall, please &lt;strong&gt;stop&lt;/strong&gt; the service using above command.&lt;br&gt;
then launch&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sc.exe delete &lt;span class="s2"&gt;"Azure Cloud STT Service"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Logging
&lt;/h1&gt;

&lt;p&gt;Classic logging is used, you can find any trace in the windows events consolle.&lt;/p&gt;

&lt;p&gt;To open (WIN+R -&amp;gt; eventvwr.msc -&amp;gt; OK)&lt;br&gt;
or search Event Viewer in the Start Menu&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The source code of solution presented in this article,is available &lt;a href="https://github.com/frontegi/AzureSTTService" rel="noopener noreferrer"&gt;at&lt;br&gt;
my GitHub repo page&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A portable release, no .Net Core installation required, can be obtained in the &lt;a href="https://github.com/frontegi/AzureSTTService/releases" rel="noopener noreferrer"&gt;GitHub Release page&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
      <category>github</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
