Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Python to realize offline Voice prompt

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use Python to achieve offline voice prompt, the article is very detailed, has a certain reference value, interested friends must read it!

Environment:

Win7 system, the external network is not connected, the host is connected to the listening speaker.

Prepare:

Voice synthesis is obviously used here, and since it is offline, it is certainly impossible to call interfaces such as Baidu AI. Installing an offline voice package is a bit exciting, so let's just use Microsoft's own Speech SDK. Note that many Ghost versions of systems may have removed this feature and need to be reinstalled. After learning online, we found that we only need to install the library pyttsx3.

Train of thought:

Put all the ringtones in a list. Then go through the list to find the next time to ring the bell at the current time. Then interpret the number of "minutes" of the difference (not accurate to seconds, just a rough reminder), and call the speech synthesis output.

Coding:

Import datetime,timeimport pyttsx3engine = pyttsx3.init () ringTimes= ["8:30", "9:00", "11:00", "14:00", "14:30", "15:30", "15:55", "16:20", "17 ringTimes= 20"] def alarmTime (): currTime=datetime.datetime.now () hmemery mpaper currcurrTime. CurrTime.second for t in ringTimes: t2=int (t.split (':) [0]) * 60+int (t.split (':) [1]) t1=h*60+m if T1

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report