Author Topic: Do you want autocad speak ?  (Read 81077 times)

0 Members and 1 Guest are viewing this topic.

Greg B

  • Seagull
  • Posts: 12417
  • Tell me a Joke!
Re: Do you want autocad speak ?
« Reply #30 on: January 18, 2007, 05:06:59 PM »
Lin-Z

don't put a space between command and the comma.


"Your command, line..."

Lin-Z

  • Guest
Re: Do you want autocad speak ?
« Reply #31 on: January 18, 2007, 05:51:06 PM »
Ohhhhhhhh, I guess I should pay closer attention when I copy/paste code.  All fixed.   :ugly:

Greg B

  • Seagull
  • Posts: 12417
  • Tell me a Joke!
Re: Do you want autocad speak ?
« Reply #32 on: January 18, 2007, 05:55:49 PM »
You are mightily welcome!

daron

  • Guest
Re: Do you want autocad speak ?
« Reply #33 on: January 18, 2007, 06:51:16 PM »
Thanks Greg. I wouldn't have seen that. Very interesting stuff.

ronjonp

  • Needs a day job
  • Posts: 7524
Re: Do you want autocad speak ?
« Reply #34 on: January 18, 2007, 09:12:34 PM »
OK....so how would one query if the user has the speakers mute set, turn the volume to high, and then return it back to the previous settings?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Big G

  • Bull Frog
  • Posts: 415
Re: Do you want autocad speak ?
« Reply #35 on: January 18, 2007, 10:29:42 PM »
hahaha love this!!!

can it be made to speak every command as its being typed on the keyboard?
I thought i seen the light at the end of the tunnel. But it was just someone with a torch bringing me more work.
"You have to accept that somedays youre the pigeon and  somedays youre the statue"

Big G

  • Bull Frog
  • Posts: 415
Re: Do you want autocad speak ?
« Reply #36 on: January 18, 2007, 11:02:08 PM »
Guess Who??

Code: [Select]
(DEFUN c:who ()
  (setq who (vlax-create-object "sapi.SpVoice"))
  (vlax-invoke who "Speak" "For Centuries, mankind has been trying to unravel the mysteries of the universe" 0)
  (vlax-release-object who)
  )

can you tell its nearly quitting time on a friday?
I thought i seen the light at the end of the tunnel. But it was just someone with a torch bringing me more work.
"You have to accept that somedays youre the pigeon and  somedays youre the statue"

terrycadd

  • Guest
Do you want autocad to speak?
« Reply #37 on: January 18, 2007, 11:58:42 PM »
Here is a function version that makes it easier to use in programming.  For my *error* function, I included:
(SayIt "Houston, we have a problem!").  Have you tried numbers yet?  It's awesome!  You have to type in "inches" and "feet" etc.  I haven't tested it while a dialog is active, but I will tomorrow.
Code: [Select]
(defun SayIt (Phrase$ / Sapi)
  (setq Sapi (vlax-create-object "Sapi.SpVoice"))
  (vlax-invoke Sapi "Speak" Phrase$ 0)
  (vlax-release-object Sapi)
  (princ)
);defun SayIt

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Do you want autocad speak ?
« Reply #38 on: January 19, 2007, 08:09:38 AM »
OK....so how would one query if the user has the speakers mute set, turn the volume to high, and then return it back to the previous settings?

Or how about turning the monitor off.

"This file will self destruct in 5 seconds." 
Then the monitor goes black
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

CADaver

  • Guest
Re: Do you want autocad to speak?
« Reply #39 on: January 19, 2007, 08:17:24 AM »
Have you tried numbers yet?  It's awesome!  You have to type in "inches" and "feet" etc. 
Try this:
3102880657' 6 7/8"
with a space between the foot mark and the six and another between the six and the three.

Patrick_35

  • Guest
Re: Do you want autocad speak ?
« Reply #40 on: January 19, 2007, 08:56:57 AM »
OK....so how would one query if the user has the speakers mute set, turn the volume to high, and then return it back to the previous settings?

Or how about turning the monitor off.

"This file will self destruct in 5 seconds." 
Then the monitor goes black

Yes, or you can do that

Code: [Select]
(setq sh (vlax-create-object "shell.application")
(vlax-invoke sh 'ShutdownWindows)

@+

HofCAD

  • Guest
Re: Do you want autocad speak ?
« Reply #41 on: January 22, 2007, 02:55:52 AM »
Dear Patrick_35 and Readers,

Question,  can I also change the voice?

Regards,
HofCAD CSI.


Code: [Select]
(defun C:speakcfg(/ @volume @rate)
(setq sapi (vlax-create-object "Sapi.SpVoice"))
(setq @volume (vlax-get-property sapi 'volume))
(vlax-put-property sapi 'volume 10)
(vlax-invoke sapi "Speak" "Do you want autocad speak with a soft volume" 0)
(vlax-put-property sapi 'volume 50)
(vlax-invoke sapi "Speak" "Do you want autocad to speak with a medium volume?" 0)
(vlax-put-property sapi 'volume 100)
(vlax-invoke sapi "Speak" "Do you want autocad to speak with a loud volume?" 0)
(vlax-put-property sapi 'volume @volume)
(setq @rate (vlax-get-property sapi 'rate))
(vlax-put-property sapi 'rate -8)
(vlax-invoke sapi "Speak" "Do you want autocad to speak with a slow rate?" 0)
(vlax-put-property sapi 'rate 5)
(vlax-invoke sapi "Speak" "Do you want autocad to speak with a fast rate?" 0)
(vlax-put-property sapi 'rate 0)
(vlax-invoke sapi "Speak" "Do you want autocad to speak with a normal rate?" 0)
(vlax-put-property sapi 'rate @rate)
(vlax-invoke sapi "Speak" "Question,         can I also change the voice?" 0)
(print (vlax-get-property (vlax-get-property Sapi 'Voice) 'Id))
(vlax-release-object sapi)
(princ)
)


http://www.microsoft.com/technet/scriptcenter/funzone/games/sapi.mspx
« Last Edit: January 22, 2007, 07:14:02 AM by HofCAD »

Patrick_35

  • Guest
Re: Do you want autocad speak ?
« Reply #42 on: January 22, 2007, 05:40:49 AM »
Yes, it's possible
An example to change the voice into French and on a female tone.
Sorry but it's in french   ^-^
http://www.zebulon.fr/astuces/tip200/Synthese-vocale-Windows-en-francais.html
And this
http://www.developpez.net/forums/archive/index.php/t-62567.html

But you can go to http://www.microsoft.com/reader/downloads/pc.asp

@+

KewlToyZ

  • Guest
Re: Do you want autocad speak ?
« Reply #43 on: January 30, 2007, 06:59:10 PM »
oh man I am having fun with this, thanks for the toys!

HofCAD

  • Guest
Re: Do you want autocad speak ?
« Reply #44 on: January 31, 2007, 03:48:01 AM »
Yes, it's possible
An example to change the voice into French and on a female tone.

Dear Patrick_35 and Readers,

I can change the voice, but is this the right way.
Another question  (vlax-invoke sapi "Speak" "Do you want autocad speak with a soft volume" 0)
ends with a zero.
I hear no change when I change it.

Regards,
HofCAD CSI.


Code: [Select]
(defun C:SpeakCfg(/ Sapi ~voice ~volume ~rate Voice VoiceMary VoiceMike
                    VoiceSam VoiceLst NumVoices @PlayWav @NoPath
                    @VoiceList @member+ @Voice&TextInput)

;**********************SubPrograms************************************************
(defun @PlayWav (Sapi WavFile / WavPath @@FindFile ObjFile)
(defun @@FindFile(WavFile / WinDir Path i DirLst)
(setq WinDir (getenv "Windir"))
(setq Path nil i 0 DirLst
(list "" "c:\\" (strcat WinDir "\\")
(strcat WinDir "\\media\\")
(strcat WinDir "\\System\\")
(strcat WinDir "\\System32\\")
(strcat WinDir "\\System64\\")
(strcat WinDir "\\System32\\drivers\\")))
(while (and (< i (length DirLst))
(= (setq Path (findfile (strcat (nth i DirLst) WavFile))) nil))
(setq i (1+ i)))
Path
)
(setq WavPath (@@FindFile WavFile))
(if (and WavPath Sapi)
(progn
(setq ObjFile (vlax-create-object "SAPI.SpFileStream.1"))
(vlax-invoke ObjFile "Open" WavPath)
(vlax-invoke Sapi "Speakstream" ObjFile 0)
(vlax-release-object ObjFile)
))
)
(defun @NoPath(s / cnt ct name)
(setq name (strcase s T))
(if (= (substr name 2 1) ":")
(setq name (substr name 3)))
(setq cnt 1 ct 0)
(repeat (strlen name)
(if (= (substr name cnt 1) "\\")
(setq ct cnt)
)
(setq cnt (1+ cnt))
)
(setq name (substr name (+ 1 ct) cnt))
)
(defun @VoiceList(Sapi / i VoiceLst Voices)
(setq Voices (vlax-invoke Sapi 'GetVoices))
(setq i 0 VoiceLst '())
(repeat (vla-get-count Voices)
(setq VoiceLst (append VoiceLst
(list (vlax-invoke (vla-item Voices i) 'GetDescription))))
(setq i (1+ i))
)
VoiceLst
)
(defun @member+ (x lst /)
(if (vl-member-if '(lambda (y) (wcmatch x y)) lst) x)
)
(defun @Voice&TextInput(voice text / SpeekContent)
(setq SpeekContent (strcat "<VOICE REQUIRED='NAME=" voice "'>" text "</VOICE>"))
)

;**********************Main Program***********************************************
(vl-load-com)
(setq Sapi (vlax-create-object "Sapi.SpVoice"))
(if (not Sapi)(progn
(load "AI_UTILS")(princ "\nWarning: For sound, first install Microsoft Speech SDK 5.1")
(ai_abort "Sapi.SpVoice" (strcat "Warning: No Speech Application Programming Interface"
" with Microsoft Speech" "\n or with the speech module in MS Office."
"\n Suggestion: Install Microsoft Speech SDK 5.1 from http://www.microsoft.com/downloads/"))
))
(setq ~voice (@NoPath (vlax-get-property (vlax-get-property Sapi 'voice) 'Id)))
(cond
((= ~voice "msmary") (setq Voice "Microsoft Mary"))
((= ~voice "msmike") (setq Voice "Microsoft Mike"))
((= ~voice "mssam") (setq Voice "Microsoft Sam"))
(t (setq Voice ~voice))
)
;The voice is normally in Microsoft Speech "Microsoft Mary",
;but in the speech module in MS Office it is "Microsoft Sam".
(setq ~volume (vlax-get-property Sapi 'Volume))
(vlax-put-property Sapi 'Volume 100)
(@playwav Sapi "notify.wav")
(vlax-invoke Sapi "Speak" (strcat "This is " Voice " speaking in AutoCAD with Sapi.     "
"Sapi is short for Speech Application Programming Interface.     "
"You can also use Sapi for playing Wave soundfiles in AutoCAD.") 0)
(@playwav Sapi "Ringin.wav")
(vlax-put-property Sapi 'Volume 10)
(vlax-invoke Sapi "Speak" "Do you want AutoCAD to speak with a soft volume?" 0)
(vlax-put-property Sapi 'Volume 50)
(vlax-invoke Sapi "Speak" "Do you want AutoCAD to speak with a medium volume?" 0)
(vlax-put-property Sapi 'Volume 100)
(vlax-invoke Sapi "Speak" "Do you want AutoCAD to speak with a loud volume?" 0)
;(vlax-put-property Sapi 'Volume ~volume)
(setq ~rate (vlax-get-property Sapi 'Rate))
(vlax-put-property Sapi 'Rate -8)
(vlax-invoke Sapi "Speak" "Do you want AutoCAD to speak with a slow rate?" 0)
(vlax-put-property Sapi 'Rate 5)
(vlax-invoke Sapi "Speak" "Do you want AutoCAD to speak with a fast rate?" 0)
(vlax-put-property Sapi 'Rate 0)
(vlax-invoke Sapi "Speak" "Do you want AutoCAD to speak with a normal rate?" 0)
;(vlax-put-property Sapi 'Rate ~rate)
(vlax-invoke Sapi "Speak" "Question,         Can I also change the voice?" 0)
(setq VoiceLst (@VoiceList Sapi))
;Gives normally with Microsoft Speech:("Microsoft Mary" "Microsoft Mike" "Microsoft Sam" "Sample TTS Voice")
;The voice "Sample TTS Voice" is not usable in a Sapi object, it is for use in TTSapp.exe and TTSappVB.exe
;Gives normally with Microsoft Office speech module:("Microsoft Sam")
(setq NumVoices(length VoiceLst))
(if (@member+ "Sample TTS Voice" VoiceLst) (setq NumVoices (1- NumVoices)))
(if (> NumVoices 1)
(vlax-invoke Sapi "Speak" (strcat "Yes. We can do this, because there are "
(itoa NumVoices) " usable voices on this system.") 0)
(progn
(vlax-invoke Sapi "Speak" (strcat "No. We can't do this, because there is only one voice on this system.  "
"  Probably, only the speech module of Microsoft Office is installed.") 0)
(princ (strcat "\nWarning: For more voices, first install Microsoft Speech SDK 5.1"
"\nfrom http://www.microsoft.com/downloads/"))))
(if (@member+ "Microsoft Mary" VoiceLst) (setq VoiceMary "Microsoft Mary"))
(if (@member+ "Microsoft Mike" VoiceLst) (setq VoiceMike "Microsoft Mike"))
(if (@member+ "Microsoft Sam" VoiceLst) (setq VoiceSam "Microsoft Sam"))
(if (and VoiceMary VoiceMike VoiceSam)
(progn
(vlax-invoke Sapi "Speak" (@Voice&TextInput VoiceMike
"My name is Microsoft Mike, and I have a question for Sam.") 0)
(vlax-invoke Sapi "Speak" (@Voice&TextInput VoiceMike
"Sam, could you say something about Mary?") 0)
(vlax-invoke Sapi "Speak" (@Voice&TextInput VoiceSam
"My name is Microsoft Sam, and I can say that Mary has a little lamb.") 0)
(vlax-invoke Sapi "Speak" (@Voice&TextInput VoiceMary
"Hi, this is Microsoft Mary and I think that Sam is joking like Mister Thomas Edison.") 0)
(vlax-invoke Sapi "Speak" (@Voice&TextInput VoiceMike
"This information is very interesting, and I would like to thank you all.") 0)
)
(progn
(vlax-invoke Sapi "Speak" "Warning      " 0)
(if (not VoiceMary) (vlax-invoke Sapi "Speak" "There is no Microsoft Mary." 0))
(if (not VoiceMike) (vlax-invoke Sapi "Speak" "There is no Microsoft Mike." 0))
(if (not VoiceSam) (vlax-invoke Sapi "Speak" "There is no Microsoft Sam." 0))
))
(@playwav Sapi "tada.wav")
(vlax-release-object sapi)
(princ)
)
« Last Edit: October 15, 2009, 01:23:22 PM by HofCAD »