IAN

import numpy as np

# Prompting user to input five data points

data_input = []

print("Please input 5 data points:")

for i in range(5):

    data_point = float(input(f"Enter data point {i + 1}: "))

    data_input.append(data_point)

# Converting list to NumPy array

data_array = np.array(data_input)

# Saving data to data.txt

np.savetxt('data.txt', data_array)

# Reading data back from data.txt

data_from_file = np.loadtxt('data.txt')

# Displaying the data

print("\nData you inputted:")

print(data_from_file)

-----------------------------------------------

# Prompting user to input five text strings

data_input = []

print("Please input 5 text strings:")


for i in range(5):

    data_point = input(f"Enter text string {i + 1}: ")

    data_input.append(data_point)


# Saving data to data.txt

with open('data.txt', 'w') as f:

    for item in data_input:

        f.write("%s\n" % item)


# Reading data back from data.txt

with open('data.txt', 'r') as f:

    data_from_file = f.readlines()


# Displaying the data

print("\nData you inputted:")

for line in data_from_file:

    print(line.strip())

-----------------------------------

import speech_recognition as sr


# Initialize the recognizer

r = sr.Recognizer()


# Use the microphone as the source for input

with sr.Microphone() as source:

    print("Say something:")

    # Listen for the first phrase and extract it into audio data

    audio = r.listen(source)


    try:

        # Recognize speech using Google Web Speech API

        text = r.recognize_google(audio)

        print("You said: " + text)

    except sr.UnknownValueError:

        print("Google Web Speech could not understand audio")

    except sr.RequestError as e:

        print("Could not request results from Google Web Speech; {0}".format(e))

---------------------------------


Comments