Skip to content

Modifying user audio

By combining a few Marvin tools, you can quickly record a user, transcribe their speech, modify it, and play it back.

Audio extra

This example requires the audio extra to be installed in order to record and play sound:

pip install marvin[audio]

Modifying user audio

import marvin

# record the user
user_audio =

# transcribe the text
user_text = marvin.transcribe(user_audio)

# cast the language to a more formal style
ai_text = marvin.cast(
    instructions="Make the language ridiculously formal",

# generate AI speech
ai_audio = marvin.speak(ai_text)

# play the result

User audio

"This is a test."

Marvin audio

"This constitutes an examination."