Python Script

Hi All,

I am trying to call a python script but not able to that.
Can anybody send me one sample by using this script

import pydub
import speech_recognition as sr
from os import path
from pydub import AudioSegment

assign files

input_file = “audio.mp3”
output_file = “audio.wav”

convert mp3 file to wav file

sound = AudioSegment.from_mp3(input_file)
sound.export(output_file, format=“wav”)
r = sr.Recognizer()
with sr.AudioFile(output_file) as source:
audio_data = r.record(source)
text = r.recognize_google(audio_data)
print(text)

I want text in a variable.

1.Create a Python Script File

  1. Use “Start Process” Activity: Drag and drop a “Start Process” activity onto the workflow.
  • Set the FileName property to the path of the Python interpreter executable (e.g., C:\Python39\python.exe).
  • Set the Arguments property to the full path of your Python script file (e.g., "C:\Path\to\your\audio_to_text.py").
  1. Capture Output: Use the “Invoke Python Method” activity to capture the output of the Python script.
  • Set the MethodName property to "GetConsoleOutput".
  • Set the TargetObject property to the output of the “Start Process” activity.
  • Set the Result property to a variable (e.g., pythonOutput).
  1. Log Output: Add a “Log Message” activity to display the captured output.
  • Set the Message property to pythonOutput.
  1. Run the Workflow: Run the workflow to execute the Python script and capture the output.The pythonOutput variable will contain the text printed by the Python script