Did you tried this script outside UiPath? Could you show you Invok Python Script activity?
Working with python in UiPath is really a PITA as it is now:
Encoding errors
You can’t work with non-ASCII without adpating your python
PYTHONPATH
Well, if you work with packages, importing other modules is quite a sport.
Traceback
Don’t ask for it You’d better have solid logs. To begin with,
# Your script with formatting
import speech_recognition as sr
import webbrowser as wb
chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
r = sr.Recognizer()
with sr.Microphone() as source:
print ('Say something')
audio = r.listen(source)
print (‘Done’)
try:
text = r.recognize_google(audio)
print('Google thinks you said:\n' + text)
wb.get(chrome_path).open(text)
except Exception:
print
If the following doesn’t fix your problem, could you please click on “Details” in the error and copy/paste the content?
Just thought about it: I’m not sure what is the standard output for your prints when launched from UiPath. In this context, I would let UiPath print the instructions. The script should return the string to print as a result and you’ll manage the resulting print from UiPath
the content is this "RemoteException wrapping System.InvalidOperationException: Error loading Python script —> RemoteException wrapping System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]: ModuleNotFoundError : No module named ‘speech_recognition’
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object ins, Object outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at UiPath.Python.Service.IPythonService.LoadScript(String code)
at UiPath.Python.Impl.OutOfProcessEngine.<>c__DisplayClass11_0.b__0()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at UiPath.Python.Activities.LoadScript.d__12.MoveNext()
— End of inner exception stack trace —
at UiPath.Python.Activities.LoadScript.d__12.MoveNext()
— End of stack trace from previous location where exception was thrown —
at UiPath.Shared.Activities.AsyncTaskCodeActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)"
the output is supposed to be like eg. when i say "open youtube.com " then it would open