Error invoking Python method

Error invoking Python method

we had written the code for text to speech in jupyter notebook then it is giving perfect output, but when we try to run this code in uipath using python activity we are getting error i.e., Error invoking Python method

18.3.3+Branch.master.Sha.dad278851683d948236b522f6a0c8dd584803e65

Source: Invoke Python Method

Message: Error invoking Python method

Exception Type: System.InvalidOperationException

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.InvalidOperationException: Error invoking Python method ----> System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: PlaysoundException :
Error 266 for command:
open “C:\Users\Nalini\Documents\UiPath\Python\9603974randomtext.mp3” alias playsound_0.8404515335860276
Unknown problem while loading the specified device driver.

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.InvokeMethod(Guid instance, String method, IEnumerable1 args) at UiPath.Python.Impl.OutOfProcessEngine.<>c__DisplayClass12_0.<InvokeMethod>b__0() at System.Threading.Tasks.Task1.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.InvokeMethod.d__16.MoveNext()
— End of inner ExceptionDetail stack trace —
at UiPath.Python.Activities.InvokeMethod.d__16.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)

@Nalini

Welcome to the UIPath Community.

Please check below thread and follow steps.

we have already tried one small example of python code in uipath ,it is working.But when we tried to run the code for text to speech through uipath we are getting this invoke method error

Hi
The error occurred here while invoking the code
kindly check whether the voice driver or the above specified driver is installed or enabled properly in your system
Cheers @Nalini

Hi @Nalini ,

It’s showing some error with the device loading… Don’t know what exactly it is.

Previously, when i tried to use tessaract OCR in my code, It asked me to involve the application exe file. May be you need to include the driver you want to use in the code itself.

Here is my code which I’m using (Just for your reference) :slight_smile:

try:
from PIL import Image
except ImportError:
import Image
import pytesseract

pytesseract.pytesseract.tesseract_cmd = r"C:\Users\hamadasi\AppData\Local\Tesseract-OCR\tesseract.exe"

#filename = ‘D:\Python screenshot\Deepfieldglass.png’

def ocr_core(filename = None):
if filename is None:
#filename = ‘D:\Python screenshot\Deepfieldglass.png’
return “file name is null”
text = pytesseract.image_to_string(Image.open(filename)) # We’ll use Pillow’s Image class to open the image and pytesseract to detect the string in the image
textfile = open(r"D:\UIPath files\Time sheets\Attachments\Deepfieldglass.txt",“w+”)
textfile.write(text)
#return text.encode(“utf-8”)
return “Successful”

#print(ocr_core(filename))

hi @HareeshMR ,
we installed play sound to get the audio in jupyter notebook . To run the same code in uipath do we need to install any other drivers
Regards,
Nalini.

hi @Palaniyappan ,

how to check whether the driver is installed.actually we already installed playsound in python

Thanks&Regards,
Nalini.

You need to include the driver application within the code as per my understanding. Try this including the exe file as above. @Nalini

2 Likes

hi @HareeshMR,
Now we got a result,but it is a audio file.The result is stored in an object.Will you please help us how to play that audio in uipath

Regards,
Nalini.

Hi @Nalini,

Can you try saving that to a file with an extention .mp3 or .mp4 … as per your requirement?

Then try to open the file using Process.Open as in the screenshot… It will open with the default media player in your machine…

image

I have given the windows media player exe there… but you need to give the path of the audio file you just saved.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.