2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Pythonで定刻にBeep音を鳴らす(Ubuntu)

Last updated at Posted at 2020-06-04

#pythonで定刻にBeep音を鳴らす(Ubuntu16.04)
pythonプログラムを起動してから何秒後かに
Beep音が欲しかったけど、なかなか鳴らせなかったのでメモします。
#環境
ubuntu 16.04
python 3.6

#プログラム

import os
import time
duration = 1  # seconds
freq = 440  # Hz

bool1 = True
elapsed_time = 0
while bool1:
    start = time.time()
    elapsed_time += time.time() - start
    if elapsed_time >= 2.5:#各自調整
        os.system('play -nq -t alsa synth {} sine {}'.format(duration, freq))
        bool1 = False

メモ程度です。。。もっと最適な方法があったら教えてください。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?