antani
This commit is contained in:
parent
e4854e9548
commit
7f0b6309ab
5 changed files with 115 additions and 1 deletions
|
@ -111,7 +111,7 @@ def transmit(name, mumble, chunk_size):
|
|||
mumble.sound_output.add_sound(data)
|
||||
buffer -= 10
|
||||
except IOError as e:
|
||||
print( " Error recording: %s"%e )
|
||||
print( " Error recording: %s"3%e 0)
|
||||
|
||||
def main():
|
||||
global is_streaming
|
||||
|
|
0
mumble-bot/bot.pya
Normal file
0
mumble-bot/bot.pya
Normal file
57
mumble-bot/bot2.py
Normal file
57
mumble-bot/bot2.py
Normal file
|
@ -0,0 +1,57 @@
|
|||
import pymumble_py3 as pymumble
|
||||
import subprocess as sp
|
||||
import time
|
||||
import sys
|
||||
import os
|
||||
import fcntl
|
||||
import audioop
|
||||
|
||||
pwd = "" # password
|
||||
server = "mumble.esiliati.org" # server address
|
||||
nick = "TubiaBot2"
|
||||
channel = "radiospore"
|
||||
port = 64738 # port number
|
||||
|
||||
# Spin up a client and connect to mumble server
|
||||
mumble = pymumble.Mumble(server, nick, password=pwd, port=port)
|
||||
# set up callback called when PCS event occurs
|
||||
mumble.set_receive_sound(1) # Enable receiving sound from mumble server
|
||||
mumble.start()
|
||||
mumble.is_ready() # Wait for client is ready
|
||||
mumble.channels.find_by_name(channel).move_in()
|
||||
mumble.users.myself.mute()
|
||||
|
||||
BUFFER = 0.2
|
||||
BITRATE = 48000
|
||||
RESOLUTION = 10 # in ms
|
||||
FLOAT_RESOLUTION = float(RESOLUTION) / 1000
|
||||
MONO_CHUNK_SIZE = BITRATE * 2 * RESOLUTION / 1000
|
||||
STEREO_CHUNK_SIZE = MONO_CHUNK_SIZE * 2
|
||||
silent = b"\x00" * int(STEREO_CHUNK_SIZE)
|
||||
cursor_time = None
|
||||
cursor_time = time.time() - BUFFER
|
||||
|
||||
while mumble.is_alive():
|
||||
|
||||
if cursor_time < time.time() - BUFFER: # it's time to check audio
|
||||
base_sound = None
|
||||
|
||||
try:
|
||||
for user in mumble.users.values(): # check the audio queue of each user
|
||||
if(user.sound.is_sound()):
|
||||
print(user["name"])
|
||||
while ( user.sound.is_sound() and int(user.sound.first_sound().time) < int(cursor_time)):
|
||||
print("perdona e dimentica"+str(user.sound.first_sound().timestamp)+" "+str(cursor_time))
|
||||
user.sound.get_sound(FLOAT_RESOLUTION) # forget about too old sounds
|
||||
|
||||
if user.sound.is_sound():
|
||||
print(user["name"]+" estraggo")
|
||||
sound = user.sound.get_sound(FLOAT_RESOLUTION)
|
||||
|
||||
except RuntimeError:
|
||||
eprint("ignored exception in stderr...")
|
||||
|
||||
cursor_time += FLOAT_RESOLUTION
|
||||
else:
|
||||
time.sleep(FLOAT_RESOLUTION)
|
||||
|
34
mumble-bot/silent-bot.py
Normal file
34
mumble-bot/silent-bot.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
import pymumble_py3 as pymumble
|
||||
import subprocess as sp
|
||||
from time import sleep
|
||||
import sys
|
||||
import os
|
||||
import fcntl
|
||||
import pyaudio
|
||||
|
||||
pwd = "" # password
|
||||
server = "mumble.esiliati.org" # server address
|
||||
nick = "TubiaBotSilente"
|
||||
channel = "radiospore_onair"
|
||||
port = 64738 # port number
|
||||
|
||||
# pyaudio set up
|
||||
CHUNK = 1024
|
||||
FORMAT = pyaudio.paInt16 # pymumble soundchunk.pcm is 16 bits
|
||||
CHANNELS = 1
|
||||
RATE = 48000 # pymumble soundchunk.pcm is 48000Hz
|
||||
|
||||
# Spin up a client and connect to mumble server
|
||||
mumble = pymumble.Mumble(server, nick, password=pwd, port=port)
|
||||
# set up callback called when PCS event occurs
|
||||
mumble.set_receive_sound(0) # Enable receiving sound from mumble server
|
||||
mumble.start()
|
||||
mumble.is_ready() # Wait for client is ready
|
||||
mumble.channels.find_by_name(channel).move_in()
|
||||
#mumble.users.myself.mute()
|
||||
|
||||
# constant capturing sound and sending it to mumble server
|
||||
|
||||
while True:
|
||||
mumble.sound_output.add_sound(bytes([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||
|
23
mumble-bot/testparams.py
Normal file
23
mumble-bot/testparams.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
import argparse
|
||||
import sys
|
||||
pwd=""
|
||||
server = "mumble.esiliati.org" # server address
|
||||
nick = "TubiaBot"
|
||||
channel = "radiospore"
|
||||
port = 64738 # port number
|
||||
is_streaming=False
|
||||
stream_always=False
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description='Regia pienamente automatizzata')
|
||||
parser.add_argument('--channel', help='Set channel')
|
||||
parser.add_argument('--name', help='Set bot nickname', default="RadioRobbot")
|
||||
parser.add_argument('--server', help='Set server', default="mumble.esiliati.org")
|
||||
parser.add_argument('--port', help='Set port', type=int)
|
||||
parser.add_argument('--stream', action='store_true', help='Ignore commands in chat and stream everything')
|
||||
|
||||
sys.argv.pop(0)
|
||||
|
||||
args = parser.parse_args(sys.argv)
|
||||
|
||||
print(args.name)
|
Loading…
Reference in a new issue