当前位置:   article > 正文

基于Whisper语音识别的实时视频字幕生成 (一): 流式播放视频帧和音频帧_whisper 流式语音识别

whisper 流式语音识别

Whishow

一款基于python的音视频在线播放器

1. 安装

pip install whishow
  • 1

2. 用法

示例 1: 简单上手

cmd:
    python -m whishow <video_path_or_url>
e.g. 
    python -m  whishow rtmp://mobliestream.c3tv.com:554/live/goodtv.sdp
  • 1
  • 2
  • 3
  • 4

示例 2: 基于python多线程流处理和流播放

	from whishow import STREAM,PLAY
    import keyboard
    import threading
    
    # init the stream reader, named stm.
    stm = STREAM()
    stm.init_state(url=url,
                    cache_size=10*60)
    # init the whishow player, and connect the audio/video stream of stm.
    ply = PLAY()
    ply.init_state(start=0,
                    chunk_size=1,
                    video_frame_shift=20,
                    audio_fps=stm.AUDIO_FPS,
                    video_fps=stm.VIDEO_FPS,
                    Q_audio_play=stm.Q_audio_play,
                    Q_video_play=stm.Q_video_play,
                    asr_results=[])

    # thread-0: esc for exit
    def engine():
        while 1:
            if keyboard.is_pressed('esc'):
                print("exit ..")
                break
            time.sleep(0.1)
        stm.running = False
        ply.running = False

    # thread-1: stream reader
    def stream():
        stm.read(video_dst_frame_size=video_dst_frame_size,
                is_play=True,
                is_asr=False)

    # thread-2: stream palyer
    def play():
        ply.run(show_subtitle=False)

    p0 = threading.Thread(target=engine,args=())
    p1 = threading.Thread(target=stream,args=())
    p2 = threading.Thread(target=play,args=())

    p0.start()
    p1.start()
    p2.start()

    p0.join()
    p1.join()
    p2.join()
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50

3. 联系我们

605686962@qq.com
coolEphemeroptera@gmail.com

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/854588
推荐阅读
相关标签
  

闽ICP备14008679号