LiveCaptionTranslator/LiveCaptionTranslator/Models/IBMWatson/IBMWatsonSpeechToTextWebsocketService.cs
/// <summary>
/// Open AudioFile and Send audio stream to Speech to text service 
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
Open AudioFile and Send audio stream to Speech to text service
Open AudioFile and Send audio stream to Speech to text service
private async Task SendAudioFileToWatson(string filePath)
        {
            using (var fileStream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                var bytes = new byte[1048576];
                while (fileStream.Read(bytes, 0, bytes.Length) > 0)
                {
                    await ws.SendAsync(new ArraySegment<byte>(bytes), WebSocketMessageType.Binary, true, CancellationToken.None);
                }
                await ws.SendAsync(CloseMessage, WebSocketMessageType.Text, true, CancellationToken.None);
            }
        }
private async Task SendAudioFileToWatson ( string filePath ) { using ( var fileStream = File . Open ( filePath , FileMode . Open , FileAccess . Read , FileShare . ReadWrite ) ) { var bytes = new byte [ 1048576 ] ; while ( fileStream . Read ( bytes , 0 , bytes . Length ) > 0 ) { await ws . SendAsync ( new ArraySegment < byte > ( bytes ) , WebSocketMessageType . Binary , true , CancellationToken . None ) ; } await ws . SendAsync ( CloseMessage , WebSocketMessageType . Text , true , CancellationToken . None ) ; } }
Open AudioFile and Send audio stream to Speech to text service
Open AudioFile and Send audio stream to Speech to text service
None
filePath
string
None