Voice broadcast program written by ChatGPT

The program test.py code is as follows

import os
import platform

def speak_text(text):
    if platform.system() == "Windows":
        os.system("powershell -Command Add-Type -AssemblyName System.Speech; (New-Object System.Speech.Synthesis.SpeechSynthesizer).Speak('" + text + "')")
    else:
        os.system("say " + text)

with open("text.txt", "r", encoding="utf-8") as file:
    text = file.read()

speak_text(text)

The content of the document is free. I put the following text.txt in the same folder as the above program test.py:

Cinnamon dogs have large ears because this is one of the breed's characteristics. The Cinnamon Dog is a beloved dog breed characterized by large ears, long coat, and intelligence. These characteristics are inherited for this dog breed, they are obtained through long-term breeding and selection. Different breeds of dogs have different characteristics, and these characteristics are changed by professional breeders through rigorous training and selection.

Run it, it's fine.

Guess you like

Origin blog.csdn.net/weixin_44345862/article/details/128965948