sta / sta/websocket-sharp

How to send audio through websocket-sharp.

Open
#373 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
6.1k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

i am trying below code. After opening i am sending audio but its failing .sent is coming false for audio.

how should i send it?

requirement is something like

using (var ws = new WebSocket(endpoint + "? format=Simple&language=en-US&Ocp-Apim-Subscription-Key=b37f5197677246609e15a445d7232d4a&X-ConnectionId=57AB5DB821D444EEA1A4C54FF8469A8A"))
{
ws.CustomHeaders = new Dictionary<string, string>() {
{ authInfo.HeaderName,authInfo.Token }, {ConnectionIdHeader,"57AB5DB821D444EEA1A4C54FF8469A8A" }
};
ws.Origin = "https://speech.platform.bing.com";
ws.OnMessage += (sender, e) =>
{

            };
            ws.OnOpen += (sender, e) =>
            {
                Console.WriteLine("Connection opened");                
                string v = "path: speech.config x - requestid: 168920F9308C4F388E59C1E6E8F5F488 x - timestamp: 2017-06-07 content - type: application / json { 'context':{ 'system':{ 'version':'1.0.00000'},'os':{ 'platform':'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36','name':'Browser','version':null},'device':{ 'manufacturer':'SpeechSample','model':'SpeechSample','version':'1.0.00000'} } }";
                ws.Send(v);
                Console.WriteLine("speech config sent.");
                //   ws.Send("path: audio x - requestid: 168920F9308C4F388E59C1E6E8F5F488 x - timestamp: 2017-06-07 content - type: PCM");
                //byte[] bytes = System.IO.File.ReadAllBytes(@"C:\Users\615114\Desktop\websocket-sharp-master\Example3\test8.wav");
                //// double splitlength= (((double)bytes.Length) / (double)8192);
                //IEnumerable<byte[]> enume = bytes.Split(8192);
                //foreach (var item in enume)
                //{
                //    ws.Send(item);
                //}

                
                using (var istream = File.OpenRead(@"C:\Users\615114\Desktop\websocket-sharp-master\Example3\test8.wav"))
                {
                    byte[] buffer = new byte[2048];
                    int bytesRead;
                    while ((bytesRead = istream.Read(buffer, 0, 2048)) > 0)
                    {
                        //   ws.Send(new ArraySegment<byte>(buffer));
                        ws.Send(buffer);
                    }
                }

            };

            ws.OnMessage += (sender, e) =>
            {


            };
            ws.OnError += (sender, e) =>
            {
                //  Console.WriteLine(e);
            };
            ws.Connect();

            //   Console.ReadKey(true);
        }

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the WebSocket.OnOpen handler and the ws.Send calls shown in the report, then inspect how websocket-sharp handles binary frames and the boolean return value. Reproduce the failure with the supplied audio-reading loop and determine whether the connection remains open and whether the complete audio payload is sent; the issue provides no named source file or test for verification.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.