Watson speech to text live stream C# code example -


i'm trying build app in c# take audio stream (from file now, later web stream) , return transcriptions watson in real time become available, similar demo @ https://speech-to-text-demo.mybluemix.net/

does know can find sample code, preferably in c#, me started?

i tried this, based on limited documentation @ https://github.com/watson-developer-cloud/dotnet-standard-sdk/tree/development/src/ibm.watsondevelopercloud.speechtotext.v1, badrequest error when call recognizewithsession. i'm not sure if i'm on right path here.

    static void streamingrecognize(string filepath)     {         speechtotextservice _speechtotext = new speechtotextservice();         _speechtotext.setcredential(<user>, <pw>);         var session = _speechtotext.createsession("en-us_broadbandmodel");          //returns initialized         var recognizestatus = _speechtotext.getsessionstatus(session.sessionid);          //  set observe         var taskobserveresult = task.factory.startnew(() =>         {             var result = _speechtotext.observeresult(session.sessionid);             return result;         });          //  results         taskobserveresult.continuewith((antecedent) =>         {             var results = antecedent.result;         });          var metadata = new metadata();         metadata.partcontenttype = "audio/wav";         metadata.datapartscount = 1;         metadata.continuous = true;         metadata.inactivitytimeout = -1;         var taskrecognizewithsession = task.factory.startnew(() =>         {             using (filestream fs = file.openread(filepath))             {                 _speechtotext.recognizewithsession(session.sessionid, "audio/wav", metadata, fs, "chunked");             }         });     } 

inside watson developer cloud - sdk's, in programming language, can see 1 folder called examples, , can access example using speech text.

the sdk has support websockets satisfy requirement of transcribing more real-time versus uploading audio file.

static void main(string[] args)         {             transcribe();             console.writeline("press key exit");             console.readline();         }          // http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/getting_started/gs-credentials.shtml         static string username = "<username>";         static string password = "<password>";          static string file = @"c:\audio.wav";          static uri url = new uri("wss://stream.watsonplatform.net/speech-to-text/api/v1/recognize");          // these should private classes use datacontractjsonserializer          // see https://msdn.microsoft.com/en-us/library/bb412179%28v=vs.110%29.aspx         // or servicestate class @ end         static arraysegment<byte> openingmessage = new arraysegment<byte>( encoding.utf8.getbytes(             "{\"action\": \"start\", \"content-type\": \"audio/wav\", \"continuous\" : true, \"interim_results\": true}"         ));         static arraysegment<byte> closingmessage = new arraysegment<byte>(encoding.utf8.getbytes(             "{\"action\": \"stop\"}"         ));         // ... more in link below 
  • access sdk c# here.
  • see api reference more information here.
  • one full example using speech text ibm watson developer here.

Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -