1

I am generating random number in python as below,

print random.randrange(100, 1000, 2)

Is there any way to convert that output to sound(audio) format..?

1
  • What should that number represent? Pitch? Duration? Start here. Commented Apr 20, 2014 at 11:40

2 Answers 2

4

If you want to change the speed:

import pyttsx
engine = pyttsx.init()
engine.setProperty('rate', 70)

voices = engine.getProperty('voices')
for voice in voices:
    print "Using voice:", repr(voice)
    engine.setProperty('voice', voice.id)
    engine.say("Hi there, how's you ?")
    engine.say("A B C D E F G H I J K L M")
    engine.say("N O P Q R S T U V W X Y Z")
    engine.say("0 1 2 3 4 5 6 7 8 9")
    engine.say("Sunday Monday Tuesday Wednesday Thursday Friday Saturday")
    engine.say("Violet Indigo Blue Green Yellow Orange Red")
    engine.say("Apple Banana Cherry Date Guava")
engine.runAndWait()
Sign up to request clarification or add additional context in comments.

Comments

2

I am not sure what you are trying to achieve. I assume you are trying to generate a random number and convert it into an audio stream. If so there is a module called PyTTSx which you need to install separately with pip. Here is a quick example

import pyttsx
import random
data = pyttsx.init()
d = str(random.randrange(100, 1000, 2))
data.say(d)
data.runAndWait()

1 Comment

Thank you boss,Its working I need exactly this.Can i slow down the voice response..?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.