gTTS (Google Text-to-Speech)

 gTTS (Google Text-to-Speech)

a Python library and CLI tool to interface with Google Translate text-to-speech API

Features

Customizable speech-specific sentence tokenizer that allows for unlimited lengths of text to be read, all while keeping proper intonation, abbreviations, decimals and more

Customizable text pre-processors which can, for example, provide pronunciation corrections

Installation   $ pip install gTTS

Example  $ gtts-cli 'hello' --output hello.mp3

More

Convert Text to Speech

from gtts import gTTS

import os

mytext = 'Welcome to Python for Engineers,A Complete solution for python programming'

language = 'en'

myobj = gTTS(text=mytext, lang=language, slow=False)

myobj.save('WelcomeMsg.mp3')


Word Guessing Game

import random

words = ['rainbow', 'computer', 'science', 'programming',

'python', 'mathematics', 'game', 'condition',

'reverse', 'return', 'board']


word = random.choice(words)

print("Guess the characters")

guesses = ' '

turns = 11

while turns > 0:

failed = 0

for char in word:


if char in guesses:

print(char)

else:

print("_")

failed += 1

if failed == 0:

print("You Win")

print("The word is: ", word)

break

guess = input("guess a character:")

guesses += guess


if guess not in word:

turns -= 1

print("Wrong")

print("You have", + turns, 'more guesses')

if turns == 0:

print("You Loose")

Test Internet Speed using Python program

import speedtest  

st = speedtest.Speedtest()

option = int(input('''What speed do you want to test in Megabits:  

1) Download Speed  

2) Upload Speed  

Your Choice: '''))

if option == 1:   

    print(st.download())    

elif option == 2:   

    print(st.upload())  

else:  

    print("Please enter the correct choice !")

Broadcasting in NumPy


 #Broadcasting
import numpy as np
# We will add,multiply, subtract  the vector v to each row of the matrix x,
x = np.array([[1,2,3], [4,5,6], [7,8,9]])
v = np.array([1, 0, 1])
print(x)
print(v)                 
y = x + v
y1= x * v
y2= x - v
print("Addition\n",y,"\n","Multiplication \n",y1,"\n","Subtraction \n",y2)