Watson IBM Speech to Text c# api - c#

I using follow example to recognize text from audio https://gist.github.com/nfriedly/0240e862901474a9447a600e5795d500 but I need also time codes, i added at line 40 "timestamps" : true, and removed "interim_results": true as I need only final results. But it broken, after { "state": "listening" } message it takes some time and raise exception like that
"Text" received message is invalid after the call Websocket.Closeasync. Websockets.In cases closeasync, so you should only use those when you do not expect to receive other data from the remote endpoint. Use "Websockets.CloseOutputAsync" to preserve the possibility of obtaining additional data, but to close the outgoing channel.
And if i set "continuous" : false, It do only the first iteration of speech (few first words before a pause), and then repeat {"state": "listening" } and freezes.
Can you help me, how to update that example to return Timecodes?

continuous: false means "only transcribe until the first pause" - so it isn't "freezing", it's just stopping when you tell it to.
The service then sends the final results followed by the second {"state": "listening"} message to indicate that it's done sending results. The example code closes the connection after that, but it sound like you're still attempting to send audio after closing the connection.
I'm not certain, but I think that timestamps and interim_results will probably work the way you want once you set continuous: false.
Although, if you only need final results, then the HTTP interface might make more sense. It's much simpler than the WebSockets one.
Finally, as I mentioned in email, the official IBM Watson .net SDK has support for Speech to Text in the development branch right now, and should have it included in a release soon.

Related

Problem with ivi.visa reading binary block data

I am writing an application which communicates with a network analyser using ivi.visa from Keysight. I often work remotely where I don't have an instrument, so I decided to write an application that can respond to the SCPI commands I need. This works ok for things like "*IDN?", but when I try to receive a binary block using ReadBinaryBlockOfByte(), the call terminates when it sees a newline character in the data.
If I set TerminationCharacterEnabled to false, all reads timeout. This is mentioned in the Keysight visa.net examples, so it doesn't seem to be an option.
So how can I read binary data?

VoiceXML - Recognize DTMF in Recording

I've been doing IVR work for a while, but we have a case where I'd love some expertise/feedback:
Is it possible to record a message where the user could press a DTMF tone to indicate a pause where we would insert our own sound? In this scenario, the user would record something like: "Good Morning, [DTMF], please call the office at [DTMF] to reconcile your account.".
Not sure whether we would chop the resulting WAV file into pieces to insert our variables, or do some post-processing before sending out our message.
Does anyone have any experience with something like this?
Thanks
Jim Stanley
Blackboard Connect
In VoiceXML you would use a record element to record a message from a user. The record element has an attribute call dtmfterm which if set to true (default setting) will terminate recording. If this attribute is set to false then recording is terminated when maxtime setting is reached or silence for the duration of finalsilence is reached. Having dtmfterm set to false will just result in the DTMF being part of the recording. Setting dtmfterm to true will result in the recording being terminated.
I have created applications that use caller created recordings but never one that manipulates the recordings like in your requirements. What you may be able to do is concatenate recordings together. Here is a QA that shows how to concatenate wav recordings using C#.
What you will have to experiment with is whether you can catch which DTMF key was pressed by using grammars. The spec eludes to this but it may be somewhat specific to the VoiceXML IVR platform that you are using. If you know what DTMF key was used then you can instruct the user to press * to insert silence and # to terminate recording. Both will terminate a recording but the logic in your VoiceXML will go right back into recording again if the * is pressed and stop the recording process completely if the # is pressed. Then you would use the concatenation to string these recording together and use a wav file with pre-recorded silence in the concatenation process that is inserted between the users recorded snippets.
From the tags it looks like you are using C# and MVC for your VoiceXML application. There is an open source project called VoiceModel that makes it easier to develop VoiceXML applications using ASP.NET MVC 4. You can read about how it handles recording in this environment here.
If you want to insert a pause and want to stay within the UI tag , So far how much work I had in IVR, the only dtmf with which we could stay within the UI is * and we would return a grammar "REPEAT" on pressing '*' , in the UI condition tag for REPEAT , you would add the silence (pause) wav file.
The recording part , we used osdmtype = record which mapped to an xslt which helped in the recording and recognising Customer's answer yes/no.
But nevertheless I'm bit confused on the requirement exactly , would need more details.
Sorry can't add comments as don't have enough Rep.
You can mail me or i can add more answers here.

Tapi3Lib Adding a new line at runtime

I am having some trouble with the interop.tapi3lib.dll (which can be DL here:dllLink)
For a reporting program i'm writing, i want to monitor all of the devices available by the tapi for their calls. Now this is working nicely when i fire up the program, although i suspect the dll is written with the purpose of modifying calls on a single extension, with very little code i can see all of the activity perfectly.
The problem arrises when a user logs out (or in) a phone (I'm using this for a cisco Callmanager). At that time i am able to capture the tapi_object which in turn can be used to determine which line is removed and added (old number and new number) but i can't register the new address for sending events.
The exception when i try:
Value does not fall within the expected range.
because the tapiclass was created before this address was available i suspect.
At the moment i have done a test which creates a single tapiclass for each line individual and 1 tapiclass for monitoring the tapiobject event, but this is eating 10 times the memory for our company's configuration (20 phones) so i dont even want to test this at the target site (+300 phones). The other option (for i can think of) is to dispose the 'old' tapiclass and create a new one after, however i'm a bit concerned with either loosing events between, getting double events between and pingpong when multiple users log in/out (creating the class takes a couple of seconds with my program)
So, what i would really like is the option to
tapi.RegisterCallNotifications(ad, true, true, TAPI3Lib.TapiConstants.TAPIMEDIATYPE_AUDIO, 2);
for newly available lines.
Bit of background for answers :)
-I am fairly new to C#, completly new to COM-interop and i know the principles of C++, but ive never written anything in it.
Any help would greatly be appriciated. (also any comments about interop and such)
Hmm, turns out I was wrong. Adding the line for notification is possible and does not throw the exception. I think i didn't remove the old line before adding the new in my old sample.

C# periodic new line reading from serial port

Checked many pages but I still find it unanswered.
My problem is as follows. I have a device, connected over RS232 to the computer. The device is sending TWICE a second a line like this:
"*X;0;bbb;cc;d;eee;f\r\n"
The fields are fixed width numeric fields. Once every minute the 0 flag raises to 1 and the "cc" changes. This number I need then.
In the C# application, I cannot get it working. Tried to use the recieve event to get the data, but the refreshed result needs 10+ seconds to be processed. This means that 10 seconds after the flag was risen i get the result. Sometimes it takes even longer.
I tried first with RecieveEvent. I even tried to fill the buffer untill it would fill the line, but again, same result. Then I tried with Timer that invokes every 300 ms and reads a line. Still the same problem.
So my question is, how to read and process up to date data from serial port?
When reading, the serial port will buffer data. This will introduce a small delay (but we're talking milliseconds, not tens of seconds). Most serial device drivers will allow you to configure the buffering, too, if it's really critical.
If you call ReadLine, you could introduce more delay, as it will wait until it receives a newline before it returns any data. Are you sure that your device is sending good newlines? Use a terminal emulator program to see exactly what the device is actually sending, as device documentation is often terrible!
I would Read raw data from the port, and then parse it myself. You may have to be more careful about receiving partial packets, but you remove all the middle-men from the picture, and you can be more tolerant (e.g. Not caring whether or not the data has newlines in it). Start a read and then write out the data you received to the debug console and you'll soon see what your program is receiving and how often, etc. This will also show you if the delay is in the serial port or in your processing of the messages
You may try serialPort1.readExisting(); then try parsing the data.
Good luck!

Receiving Invalid Data from Serial Port using SerialPort.ReadExisting()

I have written a program in .NET that listens to a particular Serial Port and processes the data that is being received. I wrote a test program using com0com (the Null-modem emulator) and my program was working fine. I even tested it with HyperTerminal and that seemed to work fine too.
However when I interfaced the software with the original device (an output received from a control system), the data received was garbled. It contained special characters. The same device when connected with Hyper Terminal produced the desired output. I changed the baud rates, parity etc but the data received was the same set of garbage characters.
I have used the DataReceived event of the SerialPort component and used the following line of code to capture data:
string data = portRecieve.ReadExisting();
Can somebody tell me where am i missing out? In the current environment, the output from the device is directly connected with a dot matrix printer which prints whatever is received on the port. The printer seems to catch what is being sent but my code couldn't.
If you ever encountered a similar scenario, Please share your findings.
Thanks
How did you set
SerialPort.DiscardNull
SerialPort.Encoding
And maybe show us an example of the special chars you are receiving.
I can think of the following reasons why the data might apperar garbled:
If there is a bad physical connection, you can sometimes just get garbage (rather than nothing at all). Try unplugging and replugging the leads - and check that you have the correct lead (e.g. do you need a nullmodem?). It looks as though you have this covered by checking in HyperTerminal.
If the baud rate, stop bits, parity are not correct - sounds like you have this one covered
You are trying to receive the data as a string. If it is not sent as plain text, or if your encoding is wrong, then it could easily appear garbage-like. Try using a binary receive and examine the raw data that you are receiving. This will tell you whether the data is just wrong or the .net conversion is screwing it up - eliminate the middle man!
It sounds to me like the device is putting the printer into some special graphics mode. If so, there is likely to be escape sequences in the data being sent to the printer, ie. character sequences starying with an escape (27, 0x1B) character.
In this case, you'll have to look at the printer manual to see what the commands do. Alternatively, you might be able to tell the device to use a simple ASCII only printer, rather than a intellifent one.

Categories

Resources