See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: text recognition

  1. #1
    I could stop if I wanted to
    Join Date
    2006-04
    Posts
    469
    Login to Give a bone
    0

    Default text recognition

    Bing AI spit this out, apparently python.
    Is there and easy way to use it for speech recognition?
    maybe someone with a compiler could make me an exe?



    import speech_recognition as sr
    import win32com.client

    # Initialize the recognizer
    r = sr.Recognizer()

    # Initialize AutoCAD
    acad = win32com.client.Dispatch("AutoCAD.Application")

    # Listen for speech
    with sr.Microphone() as source:
    print("Speak:")
    audio = r.listen(source)

    try:
    # Recognize speech using a hypothetical API
    text = r.recognize_google(audio)
    print(f"You said: {text}")

    # Send the recognized text as a command to AutoCAD
    acad.ActiveDocument.SendCommand(text + "\n")

    except sr.UnknownValueError:
    print("Could not understand audio")
    except sr.RequestError as e:
    print(f"Could not request results; {e}")
    Last edited by aaronic_abacus; 2023-10-15 at 07:33 PM.

  2. #2
    Member
    Join Date
    2023-10
    Posts
    8
    Login to Give a bone
    0

    Default Re: text recognition

    Too much fun!

    Using the Python wrappers at
    https://github.com/CEXT-Dan/PyRx

    import PyRx as Rx
    import PyGe as Ge
    import PyGi as Gi
    import PyDb as Db
    import PyAp as Ap
    import PyEd as Ed
    import traceback

    import speech_recognition as sr

    def PyRxCmd_doit():
    try:
    r = sr.Recognizer()
    with sr.Microphone() as source:
    print("Say something!")
    audio = r.listen(source)
    try:
    Ap.DocManager().sendStringToExecute(Ap.curDoc(), r.recognize_sphinx(audio)+"\n")
    print("Sphinx thinks you said " + r.recognize_sphinx(audio))
    except sr.UnknownValueError:
    print("Sphinx could not understand audio")
    except sr.RequestError as e:
    print("Sphinx error; {0}".format(e))

    except Exception as err:
    traceback.print_exception(err)
    but it cant understand me, maybe my microphone
    Command: PYLOAD
    Success module _DOIT is loaded:
    Command: DOIT
    Say something!
    Sphinx thinks you said nine months
    Command: DOIT
    Say something!
    Sphinx thinks you said it drop a line
    Command: PYLOAD
    Module _DOIT Already loaded, use pyreload
    Command: PYRELOAD
    Success module _DOIT is reloaded:
    Command: DOIT
    Say something!
    Sphinx thinks you said draw ally and that
    Command: draw Unknown command "DRAW". Press F1 for help.
    Command: ally Unknown command "ALLY". Press F1 for help.
    Command: and Unknown command "AND". Press F1 for help.
    Command: that
    Unknown command "THAT". Press F1 for help.
    Command: DOIT
    Say something!
    Sphinx thinks you said catherine so-so
    Command: catherine Unknown command "CATHERINE". Press F1 for help.
    Command: so-so
    Unknown command "SO-SO". Press F1 for help.
    Command: DOIT
    Say something!
    Sphinx thinks you said drop caught lying i'm not fun but what can
    Command: drop Unknown command "DROP". Press F1 for help.
    Command: caught Unknown command "CAUGHT". Press F1 for help.
    Command: lying Unknown command "LYING". Press F1 for help.
    Command: i'm Unknown command "I'M". Press F1 for help.
    Command: not Unknown command "NOT". Press F1 for help.
    Command: fun Unknown command "FUN". Press F1 for help.
    Command: but Unknown command "BUT". Press F1 for help.
    Command: what Unknown command "WHAT". Press F1 for help.
    Command: can
    Unknown command "CAN". Press F1 for help.
    Command: DOIT
    Say something!
    Sphinx thinks you said that i may know who
    Command: that Unknown command "THAT". Press F1 for help.
    Command: i INSERT
    *Insert a block from the Blocks palette
    Command: may Unknown command "MAY". Press F1 for help.
    Command: know Unknown command "KNOW". Press F1 for help.
    Command: who
    WHOHAS
    Command: *Cancel*
    Command: *Cancel*
    Command: *Cancel*
    Command: DOIT
    Say something!
    Sphinx thinks you said and sure he
    Command: and Unknown command "AND". Press F1 for help.
    Command: sure Unknown command "SURE". Press F1 for help.
    Command: he
    HATCHEDIT
    Select hatch object: *Cancel*
    Command: DOIT
    Say something!
    Sphinx thinks you said and sure
    Command: and Unknown command "AND". Press F1 for help.
    Command: sure
    Unknown command "SURE". Press F1 for help.
    Command: DOIT
    Say something!
    Sphinx thinks you said has she added that uh huh
    Command: has WHOHAS
    Command: she Unknown command "SHE". Press F1 for help.
    Command: added Unknown command "ADDED". Press F1 for help.
    Command: that Unknown command "THAT". Press F1 for help.
    Command: uh Unknown command "UH". Press F1 for help.
    Command: huh

  3. #3
    Member
    Join Date
    2023-10
    Posts
    8
    Login to Give a bone
    0

    Default Re: text recognition

    Sorry, I don't know how to edit my posts


    github CEXT-Dan/PyRx Python wrappers for ARX

    Code:
    import PyRx as Rx
    import PyGe as Ge
    import PyGi as Gi
    import PyDb as Db
    import PyAp as Ap
    import PyEd as Ed
    import traceback
    
    import speech_recognition as sr
    
    def PyRxCmd_doit():
        try:
            r = sr.Recognizer()
            with sr.Microphone() as source:
                print("Say something!")
                audio = r.listen(source)
            try:
                Ap.DocManager().sendStringToExecute(Ap.curDoc(), r.recognize_sphinx(audio)+"\n")
                print("Sphinx thinks you said " + r.recognize_sphinx(audio))
            except sr.UnknownValueError:
                print("Sphinx could not understand audio")
            except sr.RequestError as e:
                print("Sphinx error; {0}".format(e))
           
        except Exception as err:
            traceback.print_exception(err)

  4. #4
    Member
    Join Date
    2023-10
    Posts
    8
    Login to Give a bone
    0

    Default Re: text recognition

    BTY, I’ve wrapped a good chunk of ObjectARX for Python (still a work in progress)
    The source and compiled modules are on github.

    Played around with AI and Eye detection. Still wondering if I can train an AI to detect CAD geometry.
    But, If your drawings have cats in them, I should be able to locate them lol

  5. #5
    I could stop if I wanted to
    Join Date
    2006-04
    Posts
    469
    Login to Give a bone
    1

    Default Re: text recognition

    thanks daniel, can you show me how to use it?

  6. #6
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,540
    Login to Give a bone
    1

    Default Re: text recognition

    Quote Originally Posted by daniel806980 View Post
    Sorry, I don't know how to edit my posts
    Hi Daniel
    There is a link in the lower right of your post, next to Go Advanced. Also, you can edit your username to get rid of the numbers.
    C:> ED WORKING....


    LinkedIn

  7. #7
    Member
    Join Date
    2023-10
    Posts
    8
    Login to Give a bone
    1

    Default Re: text recognition

    Hi,
    Python for AutoCAD, search GitHub for CEXT-Dan/PyRx, there’s a release folder with installers for AutoCAD2021-2024. I’ve made wrappers for both ActiveX and ObjectARX. There should be enough samples to get you started, its still beta, but quite usable

    As far as the speech_recognition module, I only tried it once, so I’m certainly not in a good position to give advice. Except maybe a couple thoughts

    As you can see, I had to add the listener to a command. I must type the command “doit”, then speak. Doesn’t seem optimal. What would be cool is to have a background thread listening for a trigger i.e. “Hey CAD, open all recent drawings”

    The offline speech recognition engine ‘Sphinx’ didn’t work well at all, I’m betting the Google Speech Recognition engine would work better, though it requires configuration.

    AutoCAD doesn’t understand humans, but it should be possible to build a post processor, i.e. “open all recent drawings” could be mapped to a macro that opens all the recent drawings.

    What would actually be useful? I don’t think drawing geometry would be. But I could imagine.
    “open drawing …”
    “plot sheets […names…]”
    “set UCS top”
    “create new layer […name..]”

  8. #8
    I could stop if I wanted to
    Join Date
    2006-04
    Posts
    469
    Login to Give a bone
    0

    Default Re: text recognition

    Thanks Daniel
    For my purposes i just need dictation for text prompts, not system control.
    I'm working on an AI project.

  9. #9
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,540
    Login to Give a bone
    0

    Default Re: text recognition

    For that, I don't see why you need AI. Just access the system's microphone and use a voice-to-text api. I don't think you will find anything in lisp though. After you have the text, then use it to set the mtext.Value property.
    C:> ED WORKING....


    LinkedIn

  10. #10
    I could stop if I wanted to
    Join Date
    2006-04
    Posts
    469
    Login to Give a bone
    0

    Default Re: text recognition

    no, it finds detail drawings by text and attribute content, i need speech to text for the querys
    like "cleanout adapter?"
    the project IS, AI.

    and yes i want to spit out speech to GETSTRING or maybe a variable?

    the program has a *USER:* prompt .
    it would also be cool to call out commands, like lookdb, readd etc.

    the programs works with text, drawings, graphics, media and html.

    and thanks ed oops it should be speech recognition
    Last edited by aaronic_abacus; 2023-11-03 at 08:07 AM.

Page 1 of 2 12 LastLast

Similar Threads

  1. text recognition program
    By aaronic_abacus in forum AutoLISP
    Replies: 5
    Last Post: 2013-06-21, 08:43 AM
  2. 2012: OCR Text recognition error in Autodesk Raster Design 2013
    By subramanyam.josyula348947 in forum Raster Design - General
    Replies: 0
    Last Post: 2012-12-27, 12:10 PM
  3. Text Recognition
    By waltham845 in forum Raster Design - General
    Replies: 2
    Last Post: 2004-07-10, 01:43 AM
  4. Text Recognition
    By waltham845 in forum AutoCAD Map 3D - General
    Replies: 0
    Last Post: 2004-07-09, 07:37 PM
  5. Texture Recognition
    By MartyC in forum Revit - Rendering
    Replies: 4
    Last Post: 2004-01-27, 07:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •