# Python Script

**URL:** <https://forum.uipath.com/t/python-script/573056>\
**Category:** Studio\
**Tags:** activities-panel, question, studio, python, activities\
**Created:** [August 16, 2023, 7:07am UTC](https://forum.uipath.com/t/python-script/573056 "2023-08-16T07:07:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anand.t](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anand.t/32/176627_2.png) [@anand.t](https://forum.uipath.com/u/anand.t)\
**Post date:** [August 16, 2023, 7:07am UTC](https://forum.uipath.com/t/python-script/573056/1 "2023-08-16T07:07:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Moulika\_Kaviti](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/moulika_kaviti/32/403268_2.png) [@Moulika\_Kaviti](https://forum.uipath.com/u/Moulika_Kaviti)\
**Post date:** [August 16, 2023, 12:05pm UTC](https://forum.uipath.com/t/python-script/573056/2 "2023-08-16T12:05:06Z")

</div>

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
