嘟嘟地python 中的模塊將幫助您使用計算機特有的蜂鳴聲來生成音符。它完全是用 python 編寫的(使用溫聲和時間準確地說是模塊)
由於該模塊是使用編寫的溫聲,它僅適用於 Windows。該模塊僅包含一個類和一個方法,即嘟嘟地類和head()方法。
安裝:
pip install beeply
下麵是一些說明 beeply 模塊使用的示例:
示例 1
音階是音樂的音調基礎。它是一組可以產生旋律的音調。下劃線_用於聲音的音階 If_給定,它的規模將為 1
用法:
obj = notes.beeps(duration in ms)
beeps is class, it’s constructor takes an arg ( optional ) of time duration if not given it will take it as 900 ms
If given make sure it’s in ms.
obj.hear(self,duration in ms)
Python3
# import required module
from beeply.notes import *
# Creating obj of beeply
# It's has another arg of duration
# By default it's 900 ms
a = beeps()
# It's has another arg of duration
# By default it's 900 ms
a.hear('A_')
print("Done ")
# To acknowledge us
a.hear("A")
輸出:
它將在音階 1 和音階 0 處發出 A 音,您可以發出 2 聲蜂鳴聲,每次 0.9 秒。
示例 2
Python3
# import module
from beeply.notes import *
# create object with duration as argument
a = beeps(1154)
# It will sound for 1154 ms
a.hear('A_')
# But if it is
a.head('A_', 5000)
# Then it is for 5 sec i.e. 5000ms
print("Done")
輸出:
如果您在創建對象時(即實例化時)將持續時間作為參數給出,那麽如果沒有具體給出,它也將是hear函數的默認持續時間。
相關用法
- Python BeautifulSoup find_next方法用法及代碼示例
- Python BeautifulSoup next_elements屬性用法及代碼示例
- Python BeautifulSoup Tag stripped_strings屬性用法及代碼示例
- Python BeautifulSoup Tag contents屬性用法及代碼示例
- Python BeautifulSoup parent屬性用法及代碼示例
- Python BeautifulSoup append方法用法及代碼示例
- Python BeautifulSoup previous_siblings屬性用法及代碼示例
- Python BeautifulSoup previous_sibling屬性用法及代碼示例
- Python BeautifulSoup Tag get_text方法用法及代碼示例
- Python BeautifulSoup find_parent方法用法及代碼示例
- Python BeautifulSoup replace_with方法用法及代碼示例
- Python BeautifulSoup find_all_next方法用法及代碼示例
- Python BeautifulSoup Tag descendants屬性用法及代碼示例
- Python BeautifulSoup extract方法用法及代碼示例
- Python BeautifulSoup insert方法用法及代碼示例
- Python BeautifulSoup Tag children屬性用法及代碼示例
- Python BeautifulSoup find_all方法用法及代碼示例
- Python BeautifulSoup parents屬性用法及代碼示例
- Python BeautifulSoup find_previous_sibling方法用法及代碼示例
- Python BeautifulSoup find方法用法及代碼示例
- Python BeautifulSoup insert_before方法用法及代碼示例
- Python BeautifulSoup next_element屬性用法及代碼示例
- Python BeautifulSoup next_siblings屬性用法及代碼示例
- Python BeautifulSoup has_attr方法用法及代碼示例
- Python BeautifulSoup next_sibling屬性用法及代碼示例
注:本文由純淨天空篩選整理自akshaypawar4大神的英文原創作品 Beeply module in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。