16 Replies Latest reply on Aug 29, 2008 5:52 PM by wgb14

    Script parser

    wgb14 Level 1
      Hi all,
      I wonder if there is any way to accomplish the following in director:

      I have a field in which I copy the following script (different everytime but with the same tags)

      Hi <anim1=test1> my name is giannis. How are you today<anim2=test2>.

      A TTS engine should read this text and extract automatically two text files: 1) a textfile with the following format:
      2) A textfile that contains a list of the tags in the text (e.g., <anim1=test1>, etc). I know that this should be easy to do with regular expressions.

      \clock [t= X] \load [Playanimation = Y]
      \clock [t= Z] \load [Playanimation = W]


      X is where the TTS encountered anim1 (e.g., 0.1 seconds)
      Y should be the name of the animation that is only part of the anim1 tags
      Z should be the time where the TTS encounter anim2 (e.g., 0.4 seconds)
      W should be the name of the animation that is only part of anim2 tags

      Is that possible using director? please let me know with relevant Lingo examples
        • 1. Re: An interesting challenge
          wgb14 Level 1
          any ideas?
          • 2. Re: An interesting challenge
            Chunick Level 3
            if you're using MX2004 then use Javascript's built-in regular expressions - or use the PRegEx Xtra, otherwise.

            are you looking for help in writing the regular expressions that would find the relevant tags?... or for general help in coding what you've done a great job in outlining?
            • 3. Re: An interesting challenge
              wgb14 Level 1
              Well, some examples would be usefull if you have anything in mind. Its a complex problem. I can use regular expressions fine, but there are a lot of problems:

              1) How do I make the TTS engine to query the time once it will encounter the specific tag and automatically write it to a file with a specific format?

              2) How do i make the TTS engine to ignore these tags from speaking? I have been searching for hours but I can nseem to find any answers to these two questions.

              Any ideas? I am completely lost with this!
              • 4. Re: An interesting challenge
                Level 7
                Yanni,
                I doubt that anyone who can provide the help you ask finds this to be an
                'interesting challenge'.
                This forum may have various purposes, but writing (lengthy) scripts for
                specific tasks upon request is not one of them.

                Regards,
                alchemist.


                "wgb14" <webforumsuser@macromedia.com> wrote in message
                news:g957sd$jik$1@forums.macromedia.com...
                > Well, some examples would be usefull if you have anything in mind. Its a
                > complex problem. I can use regular expressions fine, but there are a lot
                > of
                > problems:
                >
                > 1) How do I make the TTS engine to query the time once it will encounter
                > the
                > specific tag and automatically write it to a file with a specific format?
                >
                > 2) How do i make the TTS engine to ignore these tags from speaking? I have
                > been searching for hours but I can nseem to find any answers to these two
                > questions.
                >
                > Any ideas? I am completely lost with this!
                >


                • 5. Re: An interesting challenge
                  wgb14 Level 1
                  "This forum may have various purposes, but writing (lengthy) scripts for
                  specific tasks upon request is not one of them."

                  I am not asking for complete scripts. I am sorry if this is not clear in my posting. All I want is some general advice/guidelines on how to approach this, and IF you know any relevant examples/scripts.

                  By the way, I have created a dll where you can add face detection in director games. If you want it, it is here

                  http://aidreams.co.uk/forum/index.php?topic=2294.0



                  • 6. Re: An interesting challenge
                    Level 7
                    > IF you know any relevant examples/scripts.
                    What you asked was far too specialized for an example to exists.
                    Try breaking your question in parts.
                    E.g.
                    Q1: I have the string: "Hi <anim1=test1> my name is giannis. How are you
                    today<anim2=test2>"
                    How can I generate from it a list like [ #text:"HI", #anim:"test1",
                    #text:"my name is giannis. How are you today", #anim:"test2" ]
                    Q2 How can I save a given string to a file?
                    etc...

                    That way, you will get exact answers and most probably examples. Many list
                    members are willing to write examples as answers to such questions.
                    It's good that you find your project interesting. In an ideal world, that's
                    how it should always be. However, don't expect that others will necessarily
                    share the same interest.

                    > By the way, I have created a dll where you can add face detection in
                    > director
                    > games. If you want it, it is here
                    Wouldn't you prefer to do it yourself? That tool I told you about is now
                    operational, but not to be publically announced yet. Mail me to send you a
                    copy you can try.


                    "wgb14" <webforumsuser@macromedia.com> wrote in message
                    news:g96b6j$r0d$1@forums.macromedia.com...
                    > "This forum may have various purposes, but writing (lengthy) scripts for
                    > specific tasks upon request is not one of them."
                    >
                    > I am not asking for complete scripts. I am sorry if this is not clear in
                    > my
                    > posting. All I want is some general advice/guidelines on how to approach
                    > this,
                    > and IF you know any relevant examples/scripts.
                    >
                    > By the way, I have created a dll where you can add face detection in
                    > director
                    > games. If you want it, it is here
                    >
                    > http://aidreams.co.uk/forum/index.php?topic=2294.0
                    >
                    >
                    >
                    >
                    >



                    • 7. Re: Script parser
                      wgb14 Level 1
                      <<Try breaking your question in parts.>>

                      I am not sure if this question can be broken in parts but the steps could be as follows (let me know if you have anything to add)

                      1) Somehow I will have to program my custom tags into the TTS and inteface them with Director.
                      2) Create a rule to test the tags encountered by the TTS. If the tag is <anim1=test1>, then query the timer and save the time instance.
                      3) Break down the string using regular expressions ( anim1,test1) and write the following in the script file:

                      \clock [t= X] \load [Playanimation = Y]

                      x is the time instance and y is the name of the animation (i.e., test1)

                      3) If the tag is animation2 then repeat the same process but write the following lines in the script file


                      \clock [t= X] \load [Playanimation2 = Y]

                      Continoue the same process untill no more tags are encountered. Meanwhile the engine should also save a wav file of the text as well as extracting the tags from the text in a seperate file. This part is not a really big problem. If I can get some hints on the first part i should be able to figure out the rest.

                      <<Wouldn't you prefer to do it yourself? That tool I told you about is now
                      operational, but not to be publically announced yet. Mail me to send you a
                      copy you can try.>>

                      Thats whay I am saying, the dll is ready and you can download it from that URL. It acts as an activex control so you can easily use it in director. If someone is willing to convert it to an xtra please email me for the source code. As for your xtra yes i will email you, failure of director to access dll has always been a massive problem.
                      • 8. Re: Script parser
                        Level 7
                        Still too much info.
                        Leaving out the tts part, is parsing a string what you are asking, or what?
                        If so, you could use something like:
                        str="blah1 <anim1> blah2 <anim2> blah3"
                        myList=[:]
                        repeat while 1
                        tagbgn=offset("<", str)
                        if tagbgn=0 then
                        if str.length then myList.addprop(#t, str)
                        exit repeat
                        end if
                        if tagbgn>1 then
                        myList.addprop(#t, str.char[1..tagbgn-1])
                        put empty into str.char[1..tagbgn]
                        end if
                        tagend=offset(">", str)
                        myList.addprop(#a, str.char[1..tagend-1])
                        put empty into str.char[1..tagend]
                        end repeat
                        put myList

                        -- [#t: "blah1 ", #a: "anim1", #t: " blah2 ", #a: "anim2", #t: " blah3"]


                        > Thats whay I am saying, the dll is ready and you can download it from that
                        > URL
                        And what I was saying is that you could mail me if you wanted to use it in
                        director.


                        "wgb14" <webforumsuser@macromedia.com> wrote in message
                        news:g96jid$6o8$1@forums.macromedia.com...
                        > <<Try breaking your question in parts.>>
                        >
                        > I am not sure if this question can be broken in parts but the steps could
                        > be
                        > as follows (let me know if you have anything to add)
                        >
                        > 1) Somehow I will have to program my custom tags into the TTS and inteface
                        > them with Director.
                        > 2) Create a rule to test the tags encountered by the TTS. If the tag is
                        > <anim1=test1>, then query the timer and save the time instance.
                        > 3) Break down the string using regular expressions ( anim1,test1) and
                        > write
                        > the following in the script file:
                        >
                        > \clock [t= X] \load [Playanimation = Y]
                        >
                        > x is the time instance and y is the name of the animation (i.e., test1)
                        >
                        > 3) If the tag is animation2 then repeat the same process but write the
                        > following lines in the script file
                        >
                        >
                        > \clock [t= X] \load [Playanimation2 = Y]
                        >
                        > Continoue the same process untill no more tags are encountered. Meanwhile
                        > the
                        > engine should also save a wav file of the text as well as extracting the
                        > tags
                        > from the text in a seperate file. This part is not a really big problem.
                        > If I
                        > can get some hints on the first part i should be able to figure out the
                        > rest.
                        >
                        > <<Wouldn't you prefer to do it yourself? That tool I told you about is now
                        > operational, but not to be publically announced yet. Mail me to send you a
                        > copy you can try.>>
                        >
                        > Thats whay I am saying, the dll is ready and you can download it from that
                        > URL. It acts as an activex control so you can easily use it in director.
                        > If
                        > someone is willing to convert it to an xtra please email me for the source
                        > code. As for your xtra yes i will email you, failure of director to access
                        > dll
                        > has always been a massive problem.
                        >
                        >


                        • 9. Re: Script parser
                          wgb14 Level 1
                          Yes, this is what I was looking for. However, there is still too much work to do in the TTS part that can be done only VB.NET.
                          • 10. Re: Script parser
                            Level 7
                            I doubt there are things that can be done ONLY with vb.net, but if you say
                            so...

                            "wgb14" <webforumsuser@macromedia.com> wrote in message
                            news:g97fdl$5rd$1@forums.macromedia.com...
                            > Yes, this is what I was looking for. However, there is still too much work
                            > to do in the TTS part that can be done only VB.NET.



                            • 11. Re: Script parser
                              wgb14 Level 1
                              Alchemist it is clear that you are not in a good mood today, but nevertheless I thank you for your answer!!!!
                              • 12. Re: Script parser
                                Level 7
                                Doesn't Director support TTS, at least to some degree? And a script that
                                parses some text and creates a text file can also be somewhat easily
                                written. Are you saying it can not be done? Am I missing something?
                                • 13. Re: Script parser
                                  wgb14 Level 1
                                  The way I think it is possible (not 100% sure yet), to solve the TTS part (the rest can be done in director easier than VB), is by tagging my text with a tag called bookmark mark (e.g., <Bookmark Mark=anim1 test1 />). Every TTS engine can process such tagged text and return the values of bookmark name (i.e., anim1) and bookmarkid (i.e., test1) into the application itself. This bookmark event fires every time the TTS encounters these tags. If I will hook up a timer to return the time that these bookmarks are encountered, then problem solved. Is this possible in Director? VB is one of the many languages that you can use to accomplish this!
                                  • 14. Re: Script parser
                                    Level 7
                                    It seems possible, if I understand correctly what you are trying to do.

                                    A script could parse through a string and find the position of each tag.
                                    For example your original sample was

                                    Hi <anim1=test1> my name is giannis. How are you today <anim2=test2>

                                    A search script could figure out that words 2 and 11 were tags because
                                    they start and end with <>.

                                    Next you would pass the string to the voiceSpeak( ) function (after
                                    replacing the tags with a real word that the TTS engine can translate).

                                    Checking voiceState( ) in an exitFrame handler (or using timer objects)
                                    you continuously check if the voice is speaking. If it is still
                                    speaking, use voiceWordPos( ) to figure out which word is currently
                                    being spoken. The first time you find that it is at (or beyond) word 2,
                                    grab the time and store it. Continue until all tags are encountered
                                    and/or the speech is done.

                                    How accurate the time stamps are will depend on how well you design the
                                    code. If your design is right, I would guess that the time stamps would
                                    be 'accurate enough', but you really haven't completely described what
                                    you are trying to achieve.



                                    wgb14 wrote:
                                    > The way I think it is possible (not 100% sure yet), to solve the TTS part (the
                                    > rest can be done in director easier than VB), is by tagging my text with a tag
                                    > called bookmark mark (e.g., <Bookmark Mark=anim1 test1 />). Every TTS engine
                                    > can process such tagged text and return the values of bookmark name (i.e.,
                                    > anim1) and bookmarkid (i.e., test1) into the application itself. This bookmark
                                    > event fires every time the TTS encounters these tags. If I will hook up a timer
                                    > to return the time that these bookmarks are encountered, then problem solved.
                                    > Is this possible in Director? VB is one of the many languages that you can use
                                    > to accomplish this!
                                    >
                                    • 15. Re: Script parser
                                      Level 7
                                      Nothing particularly wrong with my mood.
                                      What I have been trying to do from my first post was to give you some
                                      guidelines that would help you in both getting answers, and not annoying
                                      members with far shorter a fuse than mine.
                                      As for the vb.net thing, the alternative answer: anything that can be done
                                      with vb, since it can be done with c++ can be done with director. But such a
                                      statement needs proof. And the proof is not ready to be announced yet. Hence
                                      the off-list contact prompt in the previous post. Covered?


                                      "wgb14" <webforumsuser@macromedia.com> wrote in message
                                      news:g97mbt$cj8$1@forums.macromedia.com...
                                      > Alchemist it is clear that you are not in a good mood today, but
                                      > nevertheless I thank you for your answer!!!!


                                      • 16. Script parser
                                        wgb14 Level 1
                                        My apologies, I didn't intend to annoy anyone in this forum. All I wanted was indeed some general guidlines on how to solve the problem. The posting was indeed too long with too much info in it, but when I started the thread it was extremely difficult to break it into smaller pieces. However my goal was accomplished. Thanks to your suggestions, I am now well on the way to solve it.