導航:首頁 > 編程語言 > python錄入聲音

python錄入聲音

發布時間:2022-11-04 15:38:02

python如何檢聽音效卡是否有聲音進來

檢查音效卡、音箱等設備是否毀壞,連接是否常,是獨立音效卡,取下音效卡,用橡皮擦金手指,將音效卡換一個插槽,再插緊。

② Python的幾道關於聲音處理的題目

第一題
x = [...];

min_val = min(x)
sx = sorted(x)
min_2_val = sx[1]
max_3_val = xs[-3]
第二題:
x = [...]
num_0 = 0 # 0點個數
list_0 = [] # 0點下標
for (i, y) in enumerate(x):
if y == 0:

num_0 += 1

list_0.append(i)

# 播放音頻自己寫吧

③ python 如何實現發出特定頻率的聲音

你是想使用winsound庫嗎?
winsound.Beep(frequency, ration)

④ python3.0怎樣讀取另一台電腦的系統聲音,並在本機上報警提示

python版本切換全局版本切換:pyenv global anaconda-2.4.0全局切換為anaconda科學計算環境,因為,我現在也不做其他python開發,所以,無需再安裝其他環境了。查看現在的python版本:michael@michael-ThinkCentre-XXXX:~$ pyenv versionssystem2.7.13.4.1* anaconda-2.4.0 (set by /home/michael/.pyenv/version)有全局版本切換,當然也會有局部環境的切換:在test文件夾下希望切換到python3.4.1:pyenv local python3.4.1

⑤ Python程序運行結束如何加入提示音

#以下都是基於win xp+py 2.x;其他操作系統及py3.x沒試過...
1.電腦蜂鳴音:
print '\a'*7
#xp,py 2.6測試,這個絕對有BB...的聲音。。。
2.播放外部音頻文件
推薦外部模塊:winsound
代碼示例:
import winsound
PlaySound(sound)
#sound為wav文件名。
#還有其他播放其他多媒體格式的模塊,可自行google下。
3.文本語音發音
#這個我曾用文本語音來代替程序運行的文字提示,搭建平台:
winxp+MS語音庫+py_win32+py2.5(語音識別+文本發音)/py2.6(文本發音)+pyspeech(語音識別和發音模塊)/pytts(僅文本發音)
*pywin32:http://sourceforge.net/projects/pywin32/
*pyspeech:http://code.google.com/p/pyspeech/
*To download Speech SDK 5.1, Visit http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=5e86ec97-40a7-453f-b0ee-6583171b4530; Only SpeechSDK51.exe and SpeechSDK51LangPack.exe are needed.
#如果僅僅是要發音:
speak('程序運行結束!')很簡單;僅需winxp+MS語音庫+py_win32+py2.5/py2.6
發音函數代碼可以自己寫!

⑥ 如何用python讓樹莓派發出聲音

就是傳遞給函數raspberryTalk的參數。是不是很簡單呢?其實我們就是利用mplayer來播放從google翻譯傳來的真人發聲而已,就這么簡單。
此外,如果你想通過終端來調整揚聲器的音量,只需要輸入alsamixer,然後通過向上和向下箭頭來調整音量即可。 完整的代碼可以在這里找到。

⑦ python turtle庫 如何插入音樂

這個模塊是用來畫圖的,不是用來播放音樂的,你可以參考這個github上的這個項目:

tjwei/Flappy-Turtle

它使用sys 和 subprocess模塊調用系統第三方程序在後台播放音樂:

defplay_sound(name,vol=100):
file_name=name+".mp3"
ifsys.platform=="darwin":
cmds=["afplay"]
else:
cmds=["mplayer","-softvol","-really-quiet","-volume",str(vol)]
try:
Popen(cmds+[file_name])
except:
pass

如上代碼所示,它使用了mplayer在後台播放音樂。

⑧ 用python的tkinter開發界面 能不能加入聲音

用python的tkinter開發界面 能不能加入聲音
1)引入抽象基類(Abstraact Base Classes,ABCs)。
2)容器類和迭代器類被ABCs化,所以cellections模塊里的類型比Py2.5多了很多。
>>> import collections
>>> print('\n'.join(dir(collections)))
Callable
Container
Hashable
ItemsView
Iterable
Iterator
KeysView
Mapping
MappingView
MutableMapping
MutableSequence
MutableSet
NamedTuple
Sequence
Set
Sized
ValuesView
__all__
__builtins__
__doc__
__file__
__name__
_abcoll
_itemgetter
_sys
defaultdict
deque
另外,數值類型也被ABCs化。關於這兩點,請參閱 PEP 3119和PEP 3141。
3)迭代器的next()方法改名為__next__(),並增加內置函數next(),用以調用迭代器的__next__()方法
4)增加了@abstractmethod和 @abstractproperty兩個 decorator,編寫抽象方法(屬性)更加方便。

⑨ python 怎麼錄制系統聲音不只是麥克風聲音

#我可以幫你寫一段代碼,能夠錄音形成wav文件,不過要分析錄音文件的波形,你可以另外找#工具,比如cooledit,也很方便。
from sys import byteorder
from array import array
from struct import pack

import pyaudio
import wave

THRESHOLD = 500
CHUNK_SIZE = 1024
FORMAT = pyaudio.paInt16
RATE = 44100

def is_silent(snd_data):
"Returns 'True' if below the 'silent' threshold"
return max(snd_data) < THRESHOLD

def normalize(snd_data):
"Average the volume out"
MAXIMUM = 16384
times = float(MAXIMUM)/max(abs(i) for i in snd_data)

r = array('h')
for i in snd_data:
r.append(int(i*times))
return r

def trim(snd_data):
"Trim the blank spots at the start and end"
def _trim(snd_data):
snd_started = False
r = array('h')

for i in snd_data:
if not snd_started and abs(i)>THRESHOLD:
snd_started = True
r.append(i)

elif snd_started:
r.append(i)
return r

# Trim to the left
snd_data = _trim(snd_data)

# Trim to the right
snd_data.reverse()
snd_data = _trim(snd_data)
snd_data.reverse()
return snd_data

def add_silence(snd_data, seconds):
"Add silence to the start and end of 'snd_data' of length 'seconds' (float)"
r = array('h', [0 for i in xrange(int(seconds*RATE))])
r.extend(snd_data)
r.extend([0 for i in xrange(int(seconds*RATE))])
return r

def record():
"""
Record a word or words from the microphone and
return the data as an array of signed shorts.

Normalizes the audio, trims silence from the
start and end, and pads with 0.5 seconds of
blank sound to make sure VLC et al can play
it without getting chopped off.
"""
p = pyaudio.PyAudio()
stream = p.open(format=FORMAT, channels=1, rate=RATE,
input=True, output=True,
frames_per_buffer=CHUNK_SIZE)

num_silent = 0
snd_started = False

r = array('h')

while 1:
# little endian, signed short
snd_data = array('h', stream.read(CHUNK_SIZE))
if byteorder == 'big':
snd_data.byteswap()
r.extend(snd_data)

silent = is_silent(snd_data)

if silent and snd_started:
num_silent += 1
elif not silent and not snd_started:
snd_started = True

if snd_started and num_silent > 30:
break

sample_width = p.get_sample_size(FORMAT)
stream.stop_stream()
stream.close()
p.terminate()

r = normalize(r)
r = trim(r)
r = add_silence(r, 0.5)
return sample_width, r

def record_to_file(path):
"Records from the microphone and outputs the resulting data to 'path'"
sample_width, data = record()
data = pack('<' + ('h'*len(data)), *data)

wf = wave.open(path, 'wb')
wf.setnchannels(1)
wf.setsampwidth(sample_width)
wf.setframerate(RATE)
wf.writeframes(data)
wf.close()

if __name__ == '__main__':
print("please speak a word into the microphone")
record_to_file('demo.wav')
print("done - result written to demo.wav")

⑩ 用python的tkinter開發界面 能不能加入聲音

可以調用pygame模塊加入聲音,安裝一下

閱讀全文

與python錄入聲音相關的資料

熱點內容
app根據什麼看是否注冊 瀏覽:928
冰箱壓縮機燙手老跳閘 瀏覽:254
php日誌系統架構 瀏覽:453
udp獲取伺服器ip地址 瀏覽:985
能把心裡的恐懼解壓出來的視頻 瀏覽:368
三豐雲上傳伺服器流程 瀏覽:812
php類常亮 瀏覽:819
如何用紙尿褲做解壓玩具 瀏覽:608
程序員年齡和工資 瀏覽:766
壓縮空氣的特性簡介 瀏覽:564
廣樂美app是做什麼的 瀏覽:323
android的spinner屬性 瀏覽:929
店家幫平台源碼 瀏覽:973
源碼編輯器繪制圖形 瀏覽:951
長沙雲伺服器提供商 瀏覽:107
51單片機測脈沖寬度 瀏覽:286
文件夾弄成二維碼 瀏覽:283
python字典循環添加 瀏覽:692
閑置伺服器怎麼收費 瀏覽:162
閱讀app是用什麼開發的 瀏覽:37