Speech Recognition failed
-
Hello guys, I have a code where every 5 seconds the skript check if there is any keyword. But I get the error: Speech Recognition failed. I don‘t know why? My Code:
s = ui.Switch() s.frame = (970,1,600,40) def s_action(sender): global timestamp recorder = sound.Recorder('speech.m4a') recorder.record() if s.value == True: while True: if s.value == False: break elif clock2.uhrgedruckt == True: clock2.uhrgedruckt = False print('ok') elif timestamp - time.time() <= -5: recorder.stop() result = speech.recognize('speech.m4a', 'de_DE') if result[0][0] == 'Hallo': print('Du hast hallo gesagt') timestamp = time.time() recorder.record() else: print('Fehler') timestamp = time.time() recorder.record() else: pass s.action = s_action
-
@cvp it‘s the pythonista doc
-
@Python567 yes but this Pythonista doc, for Python keywords, points to standard doc. And this locale function has never worked.
-
About the shortcut, do you want to open Shortuts app, execute a shortcut and come back in your script or only open Pythonista
-
@cvp I want to execute a shortcut and come back to my skript
-
Even if I drunk too much 🍷
# https://forum.omz-software.com/topic/4480/handling-locale-date-string-conversion import datetime from objc_util import * NSDateFormatter = ObjCClass('NSDateFormatter') dateFormatter = NSDateFormatter.alloc().init() NSLocale = ObjCClass('NSLocale') deLocale = NSLocale.alloc().initWithLocaleIdentifier_(ns('de')) dateFormatter.setLocale_(deLocale) NSDate = ObjCClass('NSDate') date = NSDate.alloc().init() now = f"{datetime.datetime.now():%d/%m/%Y}" # see https://coderwall.com/p/jj6k_a/quick-guide-to-objective-c-dateformatting dateFormatter.setDateFormat_('dd/MM/yyyy') date = dateFormatter.dateFromString_(now) dateFormatter.setDateFormat_('EEEE') now_day_in_German = str(dateFormatter.stringFromDate_(date)) print(now_day_in_German)
If you want an abbreviated name, use
dateFormatter.setDateFormat_('EE')
-
@Python567 said:
I want to execute a shortcut and come back to my skript
Please, read carefully this topic and try with short script and shortcut.
I didn't retry....
-
You can also use, for month name
dateFormatter.setDateFormat_('MMM') now_day_in_German = str(dateFormatter.stringFromDate_(date)) print(now_day_in_German) dateFormatter.setDateFormat_('MMMM') now_day_in_German = str(dateFormatter.stringFromDate_(date)) print(now_day_in_German)
-
Or
dateFormatter.setDateFormat_('EEEE dd MMMM yyyy') now_day_in_German = str(dateFormatter.stringFromDate_(date)) print(now_day_in_German) # ==> Sonntag 14 Februar 2021
-
@cvp ok, but what have I to import for that?
-
@Python567 some posts above,(4 hours ago), you have a full script with the imports....
-
@cvp that?:
import datetime from objc_util import *
-
@Python567 yes, plus these lines once at begin of script
NSDateFormatter = ObjCClass('NSDateFormatter') dateFormatter = NSDateFormatter.alloc().init() NSLocale = ObjCClass('NSLocale') deLocale = NSLocale.alloc().initWithLocaleIdentifier_(ns('de')) dateFormatter.setLocale_(deLocale) NSDate = ObjCClass('NSDate') date = NSDate.alloc().init()
-
@cvp ok. I found a code with the name email, is it possible to send an email with pythonista?
-
@Python567 yes, the doc shows à functional example
-
@cvp really cool, can you send me the doc?
-
@Python567 the doc is internal to Pythonista. Search on smtplib
Swipe to left to display console, you see above a ? in a circle, tap it.
You get the doc and you have a search field that appears. Type smtplib and enter....
And read
-
@cvp great, thanks
-
@cvp by the way, can I change my Pythonista skript into a microsoft teams bot?
-
@Python567 no idea at all
-
@cvp ok, maybe an other guy can help