Speech recognition: call date and calculate offset

Hi everybody,

I'm a complete newbie in app building and MIT AI2. Everything has actually started for fun.

I'm trying to build a simple app logging for each entry: picture, text ,dates

At the moment I'm struggling managing date field.

I try to explain my starting point and my direction and please suggest me which is the best way to make it clear

At the moment I using as exercise TaifunSpeechRecognizer extension to fill text boxes.

getting to the point, I have one text box showing, let say 6th October 2024 recognized from my speech. I want to fill a new textbox with date plus let say 2 years.

The question is how I convert the speech -> text (6th October 2024) -> date format?

My idea is after speech -> date conversion to use dintDate extension to manipulate it

Any hint or lead?

1 Like

Before you go extension hunting, pull in a Clock component from the Sensors Drawer of the Designer.

It has loads of date and time conversion blocks.

Take the time to learn the three different internal formats for date/time values:

  • Instant
  • Milliseconds from 1970
  • Formatted Text
1 Like

Perhaps this will help you think... if you don't need more complex date operations...

:pray:

Lito

@>-->---

Hi @Lito

this is the sort of idea I had in mind but didn't have the knowledge to transform a thought to coding.

I have some questions about ur coding expecially why did u use the screen1.inizialize block but let me do some testing first trying to fit ur idea to my project and I'll revert with more accurate feedback

Coming from more structured languages this block coding is really fashinating!!!

Thanks a lot

1 Like

@gipsea Since you didn't post a *.aia with your code, I only used screen1.initialize block to reproduce the conditions of your question... using a fixed input... to help you to think... but you will have to adapt this to your idea.

Screen Initialize is the first event that will be triggered when the home screen is displayed on the device.

If you need more sophisticated operations with the final date, the blocks of this solution will turn such information into a date parameter that 'Clock' can manipulate with many more features »

All this code does is adapt the 'Speech' string result to the parameters that Clock accepts.

The *.aia below already contains the programming. Import it »

Converting_Speech_Text_to_Clock.aia (3.0 KB)

:pray:

Lito

@>-->---

WOW @Lito , u r a star!!!!

By the time I tried to implement ur suggestions u came back already with tons of further information.

Thanks about the screen.initialize, I thought something like what u said but didn't want to say before testing.

I implemented almost as it is and it is perfect.

I'm going to study your extra info with the Clock module for future reference but I think so far u made my day!!!!

Thanks to you, this great community and the AI2 developers

1 Like

Great! :star2:

I'm just an apprentice... a beginner... training with your case some solutions that I will need in the future, for when I do something bigger. :pray:

In the Clock drawer you will find fabulous resources to deal with temporal issues »

Lito

@>-->---

Well...I'm happy I triggered ur interest for the sake of both success.

I'm not sure u can quickly give an extra help before starting a new thread.
The app is going to be used by an international group of user (different languages) and also extra time could be +XX months and not only +2 years

Your month list is great for english speakers only. Considering time format, I would say that using some time format "MMMM" will return the month name in the spoken language. If this it true then I can convert my text to a complete time/date format able to add any amount of time regardless language.

Ar you aware of such option?
I can't find the time&date formats letters to be more precise :frowning: but I will evenctually get there;)

cheers

Lito

Your first example needs to handle day numbers greater than 9

Your second example needs to handle *st, *nd, *rd as well as *th

You could use the text segment block to remove the last two characters.

Ok.

I'm not sure if we are going off the topic now. All this is somehow related to the title...

I keep investigating and revert or open a new post. let see if moderators have something to say;)

No, it is all related to your first post.

Ok. My idea is something like this where adding 6 months or adding 24 months should not matter

I found the formatting set ups from the clock1 extra help

At the moment it counts the months correctly, for example October +6 = February but get confused with year calculation

If we forget for the sake of deeper dev the fact of english st,nd,rd and th, theoretically the squence should work...but doesn't ahahahahah

It is time to go for me but an interesting starting point for tomorow

ciao

In this case the programming becomes much more complex ...

If the app is going to be used by an International Group of Users, in different language, speech recognition should be chosen at the beginning of a list of languages, according to @taifun extension specifications...

image

At this point, a variable will have the result of the chosen language »

According to the number of possible languages ​​that will be contemplated, the date recognition of the date that is spoken will be different ... Just like the months of the year and the treatment of the date for each possibility ...

This presupposes some 'extra' blocks »

  • For each language contemplated you will need a list of months in this language ... for example »

... and in the 'event' that indicates that the language was chosen, there will be a command that 'decide' which list of months for this choice »

image

... something like a procedure for a global variable to memorize that the ongoing month list is one of them in the chosen language.


  • The treatment of the string that will isolate the number of the day - for that clock understands it - should also be different, according to the language ... because what Speech Recognition understands for October 6, 2024 in English » 6th October 2024 » will not be equal in German » 6. Oktober 2024 » or Spanish » 6 de Octubre de 2024 » ... and you will need to contemplate each of these possibilities with isolated procedures for each language, as there will be a different number of spaces between each information, the order may change of place, etc.

  • In this regard, you will need to have different operations on your project than you may or you will want to do... Assigning Labels or TextBoxes the parameters of hours, minutes, days, months or years to be added / subtracted with each date... and the formulas of the blocks should also contemplate this.

Understand that the solution indicated above is not intended to be complete that solves everything at once... it was just a model to help you think... and just as it was not contemplated the possibility of 'th', 'nd', etc.in the first example, analyzing the blocks you will be able to find solutions for everything reproducing logic.

In fact, your project looks quite ambitious for those starting... and you will take a long time reading the Helps of the language to be able to do everything you want. Isolates every problem. Perhaps, with each step, you need to open new topics to solve each question... But solving one problem at a time, every step, there will be a time when your ambitious project will be ready. Go ahead @gipsea! :pray:

Lito

@>-->---

BTW: It would be much easier if instead of the 'base date' to have to be extracted from the result of a Speech Recognition was a Datapicker.

The user would already choose the date of a calendar in their language -with one click- and would not have to process numerous adaptations to extract the relative data. I agree that it is very 'fashion' to be able to speak the date... but the code required to get around this -in many languages- it becomes much more complex.

Take a look at this post »

:pray:

Lito

@>-->---

1 Like

G'day @lilo and thanks for the helps above.

  1. regarding language setup, I'm using the taifunspeechrecognizer which has blocks about picking local language. (next step is to save on a DB as settings)
  2. string as date: I new it was a long shot try to convert string 2 date format. I did on python but string format was fix and could be easily split and convert. Playing around helped finding the critical aspects as we said the presence of st,nd,rd, th or possibly other. it is almost a dead end unless investigating all possibilities produced by speechrecognition but considering time, costs and maintenance request it is out of discussion at least for the moment
  3. Datapicker: I gave a look yesterday night but did not investigate too much or let say didn't coded to get a grip of it. It was my plan for today
  4. starting from your first code which added 2 years to the list, I played around using months. Once we get an idea about guidelines used by the developers of the module it is almost a straight forward process to manipulate actions withing the module
  5. I'm taking now a look at your link. I'm sure it is a another great starting point.

Feedback coming soon

1 Like

Dear @lilo
the datepicker is so far the solution.

I learned a lot from your suggestions plus together we reached the final config.

Now need to move on for the rest of the app.

Thanks again

1 Like

OK. Very good! :raised_hands:

PS: I'm '@Lito'... and no 'Lilo'... ^^ :ghost:

image

@>-->---

1 Like

Hi @Lito

Sorry for mistyping. In my mind I was selecting the name from the drop-down menu but it looks I wasn't

Thanks again

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.