def __init__(self, host, port, user, password=None, key_file=None, cert_file=None): self.host = host self.port = port self.player_thread = None self.mumble = pymumble.Mumble(host, port=port, reconnect=True, user=user, password=password, keyfile=key_file, certfile=cert_file)
def __init__(self): from os import getpid pid = str(getpid()) file(PIDFILE, 'w').write("%s\n" % pid) # store the process id self.simplelog = open("/tmp/mumble.simplelog", "a") self.recording = False # recording ongoing" self.audio_file = None # output audio_file self.chapters = None # chapters webvtt object self.current_chapter = None # insige a chapter (after a /gamestart, before a /gamestop) self.last_chapter_time = 0 self.captions = None # webvtt object for speakers captions self.cursor_time = None # time for which the audio is treated self.force_start = False self.force_stop = False self.force_newfile = False self.exit = False self.users = dict( ) # store some local informations about the users session # Create the mumble instance and assign callbals self.mumble = pymumble.Mumble(HOST, PORT, USER, PASSWORD, debug=DEBUG) self.mumble.callbacks.set_callback(PYMUMBLE_CLBK_USERCREATED, self.user_created) self.mumble.callbacks.set_callback(PYMUMBLE_CLBK_USERUPDATED, self.user_modified) self.mumble.callbacks.set_callback(PYMUMBLE_CLBK_USERREMOVED, self.user_removed) self.mumble.callbacks.set_callback( PYMUMBLE_CLBK_TEXTMESSAGERECEIVEDFULL, self.message_received) self.mumble.start() # start the mumble thread self.mumble.is_ready() # wait for the end of the connection process self.home_channel = self.mumble.channels.find_by_name(CHANNEL) self.home_channel.move_in() # move to the configured channel self.mumble.users.myself.mute( ) # mute the user (just to make clear he don't speak) self.loop()
def __init__(self, sys_args): signal.signal(signal.SIGINT, self.ctrl_caught) self.config = ConfigParser.ConfigParser() self.config.read("configuration.ini") host = get_args('-server', sys_args) user = get_args('-user', sys_args, default="StreamPlayerBot") port = int(get_args('-port', sys_args, default=64738)) password = get_args('-password', sys_args, default="") self.channel = get_args('-channel', sys_args, default="") self.volume = self.config.getfloat('bot', 'volume') self.playing = False self.url = None self.exit = False self.nbexit = 0 self.thread = None self.mumble = pymumble.Mumble(host, user=user, port=port, password=password, debug=self.config.getboolean( 'debug', 'mumbleConnection')) self.mumble.callbacks.set_callback("text_received", self.message_received) self.mumble.start() # start the mumble thread self.mumble.is_ready() # wait for the connection self.set_comment() self.mumble.users.myself.unmute() # by sure the user is not muted if self.channel: self.mumble.channels.find_by_name(self.channel).move_in() self.mumble.set_bandwidth(200000) self.loop()
HOST = "mumble.nue.suse.com" PORT = 64738 USER = "******" PASSWORD = "******" # input: 48kHZ mono wav - e.g. from sox INPUT -c 1 -r 48k -t wav - AUDIO_FILE = sys.argv[1] audio = wave.open(AUDIO_FILE) CHANNEL = "Breakout1" if sys.argv.__len__() > 2: CHANNEL = sys.argv[2] # 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 mumble.channels.find_by_name(CHANNEL).move_in() 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