<jupyter_start><jupyter_text>Text To Speech<jupyter_code>from gtts import gTTS
import os
mytext="Computer once meant a person who did computations, but now the term almost universally refers to automated electronic machinery. The first section of this article focuses on modern digital electronic computers and their design, constituent parts, and applications. The second section covers the history of computing. For details on computer architecture, software, and theory, see computer science."

language='en'
myobj=gTTS(text=mytext,lang=language,slow=False)
myobj.save('New.mp3')
os.system('New.mp3')<jupyter_output><empty_output><jupyter_text>Speech to Text<jupyter_code>#import library

import speech_recognition as sr

# Initialize recognizer class (for recognizing the speech)

r = sr.Recognizer()

# Reading Microphone as source
# listening the speech and store in audio_text variable

with sr.Microphone() as source:
    print("Tell Me Something")
    audio_text = r.listen(source)
    print("Time out,Thanks for telling")
# recoginize_() method will throw a request error if the API is unreachable, hence using exception handling
    
    try:
        # using google speech recognition
        print("Tell Me Something: "+r.recognize_google(audio_text, language = 'hi-IN'))
    except:
         print("Sorry, I amn't understand your Voice")<jupyter_output>Tell Me Something
Time out,Thanks for telling
Sorry, I amn't understand your Voice
{'fraction_non_alphanumeric': 0.07527624309392265, 'fraction_numerical': 0.0013812154696132596, 'mean_word_length': 5.218884120171674, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '452327', 'license': 'Unlicense', 'n_tokens_mistral': 410, 'n_tokens_neox': 395, 'n_words': 156, 'path': 'Exercise py/Major Project.ipynb', 'repo_name': 'meghasharma123/Notebook-Ex', 'size': '1448'}