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
import marvin.audio

# record the user
user_audio = marvin.audio.record_phrase()

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

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

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

# play the result
ai_audio.play()

User audio

"This is a test."

Marvin audio

"This constitutes an examination."