Conversation with azure

Eduardo Gomez 3,416 Reputation points
2022-09-13T18:38:03.727+00:00

I have an application, that uses Cognitive Services, to transcribe, and create a Word Document

240649-image.png

But this audio was 1 man speaking.

what I want to do is to format my app to support more speakers, and the end goal would be

[speaker 1]
..........
...,
..
[speaker 2]
....
...
..
[speaker 3]
..
..
..

and generate the word document with this

 private async Task ConvertToTextAsync(string FilePath)  
    {  
        // Configure speech service  
  
        var config = SpeechConfig.FromSubscription(Config.Constants.AZURE_KEY, Config.Constants.AZURE_REGION);  
  
        // Configure speech recognition  
  
        var taskCompleteionSource = new TaskCompletionSource<int>();  
  
        using var audioConfig = AudioConfig.FromWavFileInput(FilePath);  
        using var speechRecognizer = new SpeechRecognizer(config, audioConfig);  
        speechRecognizer.Recognizing += SpeechRecognizer_Recognizing;  
        speechRecognizer.Recognized += SpeechRecognizer_Recognized;  
        speechRecognizer.SessionStarted += SpeechRecognizer_SessionStarted;  
        speechRecognizer.SessionStopped += SpeechRecognizer_SessionStopped;  
  
        await speechRecognizer.StartContinuousRecognitionAsync().ConfigureAwait(false);  
  
        Task.WaitAny(new[] { taskCompleteionSource.Task });  
  
        await speechRecognizer.StopContinuousRecognitionAsync().ConfigureAwait(false);  
    }  
  
    private void SpeechRecognizer_SessionStopped(object? sender, SessionEventArgs e)  
    {  
  
        var path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);  
        var folder = Path.Combine(path, "Transcribed");  
        var filename = Path.Combine(folder, "Hello.docx");  
        Directory.CreateDirectory(folder);  
  
        var sb = new StringBuilder();  
  
        foreach (var item in Words)  
        {  
            sb.Append(item);  
        }  
  
        using var document = new WordDocument();  
  
        document.EnsureMinimal();  
  
        document.LastParagraph.AppendText(sb.ToString());  
  
        document.Save(filename);  
  
        MessageBox.Show("Created");  
    }  
  
    private void SpeechRecognizer_SessionStarted(object? sender, SessionEventArgs e)  
    {  
        Debug.WriteLine("Started");  
    }  
    private void SpeechRecognizer_Recognized(object? sender, SpeechRecognitionEventArgs e)  
    {  
        if (e.Result.Reason == ResultReason.RecognizedSpeech)  
        {  
            foreach (var item in e.Result.Text)  
            {  
                Words.Add(item);  
            }  
        }  
    }  
  
    private void SpeechRecognizer_Recognizing(object? sender, SpeechRecognitionEventArgs e)  
    {  
    }  
}  

240676-image.png

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,648 questions
{count} votes