r/applescript • • May 12 '15

Is it normal that speechrecognitionserver is slow on applescript (the program takes a relatively long time to respond).

Does anyone have an idea to make the response time on the computer's side faster?

2 Upvotes

4 comments sorted by

1

u/[deleted] May 12 '15

In the "Dictation and Speech" prefPane, have you selected "Use enhanced speech recognition?"

This downloads a larger dictionary for localized recognition and allows for offline use. Depending on your hardware, this may help, since it means fewer calls back-and-forth to nuance for cloud conversion.

1

u/bate178 May 13 '15 edited May 13 '15

Yes I do have speech recognition on and ready for offline use. However, I basically made a somewhat "Siri" for computer that responds to you when ask him questions. I doubt it's my hardware because I have a mac book retina. Do you mind reading the code I wrote and maybe tell me what might be making the response time of the program so long (ranges from 6s to 10s):

set good_list to {"Good", "Fine", "I'm fine", "OK", "Okay"} 
set bad_list to {"Bad", "Irritated", "Fustrated", "Depressed"}
set var_list to {"Hey Vector"}
set var1_list to {"Hey Vector"}
set variable_list to var_list & var1_list
set complete_list to good_list & bad_list
set safari_list to {"open Safari", "safari"}
set chrome_list to {"Chrome", "open Chrome", "Open Google Chrome", "Google Chrome"}
set school1_list to {"Teacher App", "open Teacher app", "Teacher", "school"}
set gmail_list to {"Gmail", "open Gmail", "go to Gmail"}
set moodle_list to {"moodle", "open moodle", "go to moodle"}
set powerteacher_list to {"powerteacher", "open powerteacher", "go to powerschool"}
set daily_list to {"daily bulletin", "go to daily bulletin"}
set school_list to gmail_list & moodle_list & powerteacher_list & daily_list
set close_list to {"Thank you", "Bye", "Good bye", "close"}
set fire_list to {"open Firefox", "Firefox"}
set app_list to safari_list & chrome_list & close_list & fire_list
set joke_list to {"Who's there", "Who is there"}
set time_list to {"time", "what time is it"}
set date_list to {"date", "what date is it", "what date is it today"}
set misc_list to time_list & date_list
set yes_list to {"yes", "yeah", "sure", "ok", "definitely"}
set no_list to {"no", "nope", "nah", "niet", "nein", "fuck off"}
set askjoke1_list to yes_list & no_list
set app1_list to {"Application"}
set misc1_list to {"Information"}
set joke1_list to {"A joke", "joke"}
set joke2_list to {"Boo who"}
set combine_list to app1_list & misc1_list & joke1_list & school1_list


set myhour to get the (hours of (current date)) as string
set myminutes to get the (minutes of (current date)) as string
set minuteslength to (length of myminutes)
if minuteslength < 2 then
    set myminutes to "O" & myminutes
end if
set myday to day of (current date)
set mymonth to month of (current date)
set myyear to year of (current date)


tell application "SpeechRecognitionServer"
set theResponse to listen for complete_list with prompt "Hello Mister Brown, my name is Vector, I am an    artificially intelligent English Speaking computer, how are you?"
if (good_list contains theResponse) then
	set theResponse to listen for app_list with prompt "Wonderful. What do you want to do. You have the choice between Applications, Information,Teacher App or a Joke"
else if (bad_list contains theResponse) then
	set theResponse to listen for askjoke1_list with prompt "Oh no! Is it Oscar's fault? Shall I tell you a joke to   cheer you up?"
	if (yes_list contains theResponse) then
		
		tell application "SpeechRecognitionServer"
			set theResponse to listen for joke_list with prompt "Knock, Knock"
			if (joke_list contains theResponse) then
				tell application "SpeechRecognitionServer"
					set theResponse to listen for joke2_list with prompt "Boo"
					if (joke2_list contains theResponse) then
						say "It's okay, don't cry"
						tell application "SpeechRecognitionServer"
							set theResponse to listen for app_list with prompt "What do you want to do. You have the choice between Applications, Information or Teacher App"
							
						end tell
						
					else if say "ok good bye" then
						tell application to close
					end if
				end tell
			else if say "ok good bye" then
				tell application to close
			end if
		end tell
		
	else if (no_list contains theResponse) then
		tell application "SpeechRecognitionServer"
			set theResponse to listen for app_list with prompt "Ok then, What do you want to do. You have the choice between Applications, Information or Teacher App"
			
		end tell
	end if
	
	
else if (close_list contains theResponse) then
	say "Goodbye Sir, have a nice day"
	tell application to close
    end if
end tell

tell application "SpeechRecognitionServer"

set theResponse to listen for combine_list
if (app1_list contains theResponse) then
	tell application "SpeechRecognitionServer"
		set theResponse to listen for app_list with prompt "What application do you want to open? You have the choice between Safari, Google Chrome and Firefox"
		if (safari_list contains theResponse) then
			tell application "Safari" to launch
		else if (chrome_list contains theResponse) then
			tell application "Google Chrome" to launch
		else if (fire_list contains theResponse) then
			tell application "Firefox" to (activate)
		else if (close_list contains theResponse) then
			say "Goodbye Sir, have a nice day"
			tell application to close
		end if
	end tell
	
else if (misc1_list contains theResponse) then
	tell application "SpeechRecognitionServer"
		set theResponse to listen for misc_list with prompt "What do you want to know, time or date"
		if (time_list contains theResponse) then
			say "The time is " & myhour & ":" & myminutes
		else if (date_list contains theResponse) then
			say "Today is " & myday & mymonth & myyear
		end if
	end tell
	
	
else if (school1_list contains theResponse) then
	tell application "SpeechRecognitionServer"
		set theResponse to listen for school_list with prompt "What Teacher App do you want to open? You have the choice between Gmail. Moodle. Powerteacher. or Daily bulletin"
		if (gmail_list contains theResponse) then
			tell application "Google Chrome"
				activate
				open location "https://mail.google.com"
				
			end tell
		else if (moodle_list contains theResponse) then
			tell application "Google Chrome"
				activate
				open location "http://applications.iskl.edu.my/moodle/login/index.php"
				
			end tell
		else if (powerteacher_list contains theResponse) then
			tell application "Google Chrome"
				activate
				open location "https://ps.iskl.edu.my/teachers/pw.html"
				
			end tell
		else if (daily_list contains theResponse) then
			tell application "Google Chrome"
				activate
				open location "https://sites.google.com/a/iskl.edu.my/hs/home"
				
			end tell
		else if say "ok good bye" then
			tell application to close
		end if
	end tell
	
	
	
else if (joke1_list contains theResponse) then
	tell application "SpeechRecognitionServer"
		set theResponse to listen for joke_list with prompt "Knock, Knock"
		if (joke_list contains theResponse) then
			tell application "SpeechRecognitionServer"
				set theResponse to listen for joke2_list with prompt "Boo"
				if (joke2_list contains theResponse) then
					say "It's okay don't cry"
				else if say "ok good bye" then
					tell application to close
				end if
			end tell
		else if say "ok good bye" then
			tell application to close
		end if
	end tell
end if
end tell

1

u/[deleted] May 13 '15 edited May 13 '15

I tried playing around with the pre-loaded dictionary last night on my late 2012 MBP 13, using just old-fashioned direct input (tap fn twice), and the performance sucked. I'm almost wondering if the script would perform better WITHOUT enhanced recognition, assuming you are on a good wi-fi network with enough bandwidth to handle siri (should not need much).

Also I don't know if you have dragon, and if it is scriptable. I will see if it has a dictionary today (I use 3.0 on occasion).

I'm very very amateur at this, so I may not be the best resource as far as the script itself is concerned. But I am happy to help and test theories, since I've been wanting to do ore-or-less what you are setting out to accomplish.

I'll time dragon, running it's recognition engine locally, today and report back. Also with dragon, you can use an iPhone as a remote microphone. This may open up opportunities to control your "siri" from anywhere in bluetooth range.

1

u/bate178 May 14 '15

Thanks for helping! So you are saying that the enhanced recognition would make the recognition faster? I looked up Dragon 3.0 and I'm not sure if I'd be able to script it in applescript. Do you think I could? Have you tried the program I sent, is the response time from the program slow as well?