forked from Robert904/mumblerecbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
basicplayer.py
43 lines (28 loc) · 1.02 KB
/
basicplayer.py
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
# -*- coding: utf-8 -*-
import wave
import time
import sys
import pymumble
from pymumble import pyopus
DEBUG = False
HOST = "localhost"
PORT = 64738
USER = "player"
PASSWORD = "player"
AUDIO_FILE = sys.argv[1]
# create the mumble instance
mumble = pymumble.Mumble(HOST, PORT, USER, PASSWORD, debug=DEBUG)
mumble.start() # start the mumble thread
mumble.is_ready() # wait for the connection
mumble.users.myself.unmute() # by sure the user is not muted
audio=wave.open(AUDIO_FILE)
start = time.time()
frames = audio.readframes(480)
while frames:
while mumble.sound_output.get_buffer_size() > 0.5:
time.sleep(0.01) # if mumble outgoing buffer is full enough, wait a bit
mumble.sound_output.add_sound(frames) # send a piece of audio to mumble
frames = audio.readframes(480)
while mumble.sound_output.get_buffer_size() > 0: # wait for the output buffer to empty
time.sleep(0.01) # wait for the mumble buffer's exhaustion before exiting
audio.close()