Organize python code for execution on uipath

you are on the right track. The function doesn’t return anything which is why you are probably seeing that error.

try this modified code. added a return statement instead of print:
If it doesn’t work, try debugging in your IDE and let me know which line no is it erroring on.

import speech_recognition as sr
import time
from pydub import AudioSegment
from pathlib import Path

def convert_audio_to_text(src):

    dst = Path(src).with_suffix('.wav')

    # convert wav to mp3                                                            
    audSeg = AudioSegment.from_mp3(src)
    audSeg.export(dst, format="wav")

    r = sr.Recognizer()
    with sr.AudioFile(dst) as source:
        audio = r.listen(source)

        try:
            print("Reading audio file. Please, wait a moment...")
            text = r.recognize_google(audio, language='en-US')
            time.sleep(1.5)
            # print(text)
            return text
        except:
            return "I am sorry! I can not understand!"




x = convert_audio_to_text('C:\\Users\\TTssRpaConba\\Desktop\\audio.mp3')
print(x)