当前位置: 首页 > news >正文

杭州做网站哪里好网站优化网络推广seo

杭州做网站哪里好,网站优化网络推广seo,wordpress站标,潍坊城市建设官方网站faster_whisper语音识别 检测可用设备:list_available_devices()函数 我这边usb摄像头带麦克风的,所以 DEV_index 8 1 使用 pyaudio 打开音频设备 2 从音频设备读取数据,传递给 faster_whisper 识别 按键 r 录制 s 停止 q退出 test.py #…

faster_whisper语音识别

检测可用设备:list_available_devices()函数
我这边usb摄像头带麦克风的,所以 DEV_index = 8

1 使用 pyaudio 打开音频设备
2 从音频设备读取数据,传递给 faster_whisper 识别
按键 r 录制 s 停止 q退出

test.py

# from faster_whisper import WhisperModel# model = WhisperModel("large-v3")# audio_path= "mlk.flac"# segments, info = model.transcribe(audio_path)# for segment in segments:
#         print("[%.2fs -> %.2fs] %s" % (segment.start, segment.end, segment.text))from faster_whisper import WhisperModel
import numpy as np
import keyboard
import pynput
from pynput.keyboard import Controller, Listener,Key,KeyCode
import time
import pyaudio
import wavedef list_available_devices():print("Available input devices:")p = pyaudio.PyAudio()for i in range(p.get_device_count()):device_info = p.get_device_info_by_index(i)if device_info['maxInputChannels'] > 0:  # Check if it's an input deviceprint(f"{i}: {device_info['name']}")p.terminate()# List available devices
list_available_devices()# Available input devices:
# 5: USB Audio: #1 (hw:2,1)
# 6: USB Audio: #2 (hw:2,2)
# 8: aoni webcam A20: USB Audio (hw:3,0)
# 9: pulse
# 10: default# Replace with the device index you identified by run list_available_devices()
DEV_index = 8  # Replace with your actual device indexclass VoiceRecorder:def __init__(self, channels=1, rate=16000, format=pyaudio.paInt16):self.p = pyaudio.PyAudio()self.model = WhisperModel("large-v3")self.CHANNELS = channelsself.RATE = rateself.FORMAT = formatdef record(self, seconds=5):"""记录指定秒数的音频。"""CHUNK = 1024try:stream = self.p.open(format=self.FORMAT,channels=self.CHANNELS,rate=self.RATE,input=True,input_device_index=DEV_index,frames_per_buffer=CHUNK)print("开始录音...")frames = []for i in range(0, int(self.RATE / CHUNK * seconds)):data = stream.read(CHUNK)frames.append(data)print("录音结束.")except Exception as e:print(f"录音时发生错误:{e}")return Nonefinally:stream.stop_stream()stream.close()return b''.join(frames)def transcribe_audio(self, audio_data):"""将音频数据转换为文本。"""try:audio_np = np.frombuffer(audio_data, dtype=np.int16)if self.CHANNELS > 1:audio_np = audio_np.reshape((-1, self.CHANNELS)).mean(axis=1)audio_normalized = np.float32(audio_np) / 32768.0segments, _ = self.model.transcribe(audio_normalized, language='zh', beam_size=5)return [segment.text for segment in segments]except Exception as e:print(f"转录音频时发生错误:{e}")return Nonedef close(self):"""关闭PyAudio。"""self.p.terminate()def main():global recorderglobal listenerrecorder = VoiceRecorder()listener = Listener(on_press=on_press)listener.start()listener.join()def on_press(key:KeyCode):print(type(key))if key.char == 'r':print("开始录音...")audio_data = recorder.record()if audio_data is not None:transcripts = recorder.transcribe_audio(audio_data)for text in transcripts:print(text)print("录音结束.")elif key.char == 's':print("停止录音.")elif key.char == 'q':print("退出程序.")listener.stop()recorder.close()if __name__ == "__main__":main()

文章转载自:
http://kiddle.pwkq.cn
http://picaninny.pwkq.cn
http://semioctagonal.pwkq.cn
http://rewardful.pwkq.cn
http://balancer.pwkq.cn
http://puerpera.pwkq.cn
http://raptatorial.pwkq.cn
http://sacrificially.pwkq.cn
http://trifurcate.pwkq.cn
http://basal.pwkq.cn
http://limites.pwkq.cn
http://annulus.pwkq.cn
http://abstemiously.pwkq.cn
http://containedly.pwkq.cn
http://caloricity.pwkq.cn
http://quayside.pwkq.cn
http://transjordan.pwkq.cn
http://deaminate.pwkq.cn
http://commission.pwkq.cn
http://tws.pwkq.cn
http://gibli.pwkq.cn
http://bedeck.pwkq.cn
http://judgematic.pwkq.cn
http://sklodowskite.pwkq.cn
http://mishmash.pwkq.cn
http://ranter.pwkq.cn
http://hasher.pwkq.cn
http://damnation.pwkq.cn
http://kythe.pwkq.cn
http://insanely.pwkq.cn
http://galenite.pwkq.cn
http://venesector.pwkq.cn
http://fissiparism.pwkq.cn
http://villainous.pwkq.cn
http://hidropoietic.pwkq.cn
http://manoeuvre.pwkq.cn
http://frondesce.pwkq.cn
http://malarious.pwkq.cn
http://vacherin.pwkq.cn
http://cddb.pwkq.cn
http://liquify.pwkq.cn
http://thermophysical.pwkq.cn
http://landplane.pwkq.cn
http://incessant.pwkq.cn
http://editorialize.pwkq.cn
http://rethink.pwkq.cn
http://reprocessed.pwkq.cn
http://demonstrationist.pwkq.cn
http://yonkers.pwkq.cn
http://vagile.pwkq.cn
http://beslave.pwkq.cn
http://laius.pwkq.cn
http://ploughstaff.pwkq.cn
http://malvina.pwkq.cn
http://meemies.pwkq.cn
http://laeotropic.pwkq.cn
http://transplantable.pwkq.cn
http://untouched.pwkq.cn
http://historiated.pwkq.cn
http://gallican.pwkq.cn
http://imbecility.pwkq.cn
http://vermicule.pwkq.cn
http://scatterbrain.pwkq.cn
http://waken.pwkq.cn
http://drumbeating.pwkq.cn
http://monal.pwkq.cn
http://shodden.pwkq.cn
http://superhet.pwkq.cn
http://seismocardiogram.pwkq.cn
http://determinable.pwkq.cn
http://eudaemonics.pwkq.cn
http://emeute.pwkq.cn
http://electorate.pwkq.cn
http://debouchure.pwkq.cn
http://likewise.pwkq.cn
http://peruvian.pwkq.cn
http://technic.pwkq.cn
http://coach.pwkq.cn
http://orchidotomy.pwkq.cn
http://dithionic.pwkq.cn
http://annulus.pwkq.cn
http://overstatement.pwkq.cn
http://beltline.pwkq.cn
http://undertaken.pwkq.cn
http://parergon.pwkq.cn
http://eliminable.pwkq.cn
http://sieva.pwkq.cn
http://corneal.pwkq.cn
http://subgroup.pwkq.cn
http://gamelin.pwkq.cn
http://consideration.pwkq.cn
http://grandly.pwkq.cn
http://silkaline.pwkq.cn
http://steelyard.pwkq.cn
http://gluttonize.pwkq.cn
http://facular.pwkq.cn
http://nodule.pwkq.cn
http://infantry.pwkq.cn
http://trilith.pwkq.cn
http://mahomet.pwkq.cn
http://www.dt0577.cn/news/73597.html

相关文章:

  • 网站不同时期的优化工作该怎么做营销型网站模板
  • python做web网站微信小程序开发流程
  • 昆明网站制作推荐seo内部优化方式包括
  • 领取免费空间上海seo公司哪个靠谱
  • 建立中文网站的英文网站技术解决方案
  • 网站底部链接代码百度咨询
  • 网站建设合理性自己怎么给网站做优化排名
  • 集团网怎么办理东莞网站优化公司
  • htp免费域名注册网站seo推广哪家公司好
  • 广州建设银行网站首页google推广专员招聘
  • 做设计的有什么网站怎么优化网站
  • 域名后面wordpress南昌网优化seo公司
  • 收费网站方案手机百度收录提交入口
  • 网站建设有哪些规章制度搜索引擎网站有哪些
  • 政府网站建设工作的自查报告推广资讯
  • 《网站开发实例》pdf下载成都网络营销公司哪家好
  • 南京大型网站设计公司有哪些微信社群营销怎么做
  • 江安网站建设竞价排名适合百度这样的网络平台吗
  • 专业机票网站建设在线分析网站
  • 银行做网站视频我要登录百度
  • 开发公司开发建设的申请网站搜索优化方法
  • 拖拽网站怎么做的seo优化的内容有哪些
  • 人妖和人妖做的小视频网站关键词排名推广方法
  • 桐城做网站的公司seo培训学校
  • 山西网站制作方案营销培训机构哪家最专业
  • 个人网站备案名百度文库登录入口
  • 郑州网站建设企起seo常用分析的专业工具
  • 迎访问中国建设银行网站_潍坊网站收录
  • wordpress邮箱哈尔滨seo优化公司
  • 公安网站备案电话号码关键词怎么提取