I'm trying to take a dataframe :
NeuroScience_df = pd.read_csv('ns_def_test.csv', delimiter='-')
and run it thru a function that randomly iterates through the dataframe and prints out variables in each row while waiting for user input:
def df_values_to_vars():
func_that_shuffles_index = func_that_shuffles_index(NeuroScience_df)
the_results = '' # Create an empty string to store the results
for _, row in NeuroScience_df.loc[shuffled_index].iterrows():
name = f"name {row['name']}"
description = f"description {row['description']}"
the_results += f"{name}\n{description}\n{'-' * 100}\n"
print(the_results)
_ = input("Press enter to continue: ")
return the_results
results = df_values_to_vars()
and then, convert the results of the df_values_to_vars()
function to text to speech.
def convert_df_values_to_speech(df_func):
results = df_func() # Call the provided function to get the results
engine = pyttsx3.init()
engine.setProperty("rate", 200) # Speed of speech
engine.setProperty("volume", 0.8) # Volume level (0.0 to 1.0)
voices = engine.getProperty("voices")
for voice in voices:
if "english" in voice.languages:
engine.setProperty("voice", voice.id)
break
for result in results:
engine.say(results)
engine.runAndWait()
But in the function , convert_df_values_to_speech
,pyttsx3 spells out each letter instead of saying a sentence normally. How can I fix this?