Skip to content

Commit

Permalink
option to not generate the captions files
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed May 5, 2014
1 parent fefd5be commit 3026f10
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
7 changes: 5 additions & 2 deletions constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#send encoder STDOUT/STDERR to the console
DEBUG_ENCODER = True

#Creates the caption and chapter webvtt files
CREATE_WEBVTT = True

SAVEDIR = "c:\\temp" # folder where to save the recordings
BUFFER = 0.1 # time to buffer audio input
PIDFILE = "c:\\temp\\mumblerecbot.pid" # location to store the process id
Expand Down Expand Up @@ -33,9 +36,9 @@
STEREO_CHUNK_SIZE = MONO_CHUNK_SIZE * 2

# command to send the audio in a pipe for external encoding. %s will be replaced by a generated name
ENCODER = "/usr/bin/oggenc --raw --raw-bits=16 --raw-chan=2 --raw-rate=48000 --quality=4 --quiet -o %s.ogg -"
#ENCODER = "/usr/bin/oggenc --raw --raw-bits=16 --raw-chan=2 --raw-rate=48000 --quality=4 --quiet -o %s.ogg -"
#ENCODER = "oggenc2 --raw --raw-bits=16 --raw-chan=2 --raw-rate=48000 --quality=4 --quiet -o %s.ogg -"
#ENCODER = "ffmpeg -f s16le -ar 48000 -ac 2 -i - -c:a libmp3lame -ab 96k -ac 1 -ar 22050 -f rtp rtp://localhost:1935/"
ENCODER = "ffmpeg -f s16le -ar 48000 -ac 2 -i - -c:a libmp3lame -ab 96k -ac 1 -ar 22050 -f rtp rtp://localhost:1935/"

# comment to be shown in mumble for the recorder user
COMMENT_SUFFIX = "<br>/start:forced" + \
Expand Down
37 changes: 20 additions & 17 deletions mumblerecbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,20 +190,22 @@ def loop(self):
#create the files
audio_file_name = os.path.join(SAVEDIR, "mumble-%s" % time.strftime("%Y%m%d-%H%M%S"))
self.audio_file = AudioFile(audio_file_name)
self.chapters = webvtt.WebVtt(audio_file_name + "-chapters.vtt")
self.captions = webvtt.WebVtt(
audio_file_name + "-captions.vtt",
regions=[
"Region: id=left width=50% regionanchor=0%,100% viewportanchor=0%,100%",
"Region: id=right width=50% regionanchor=100%,100% viewportanchor=100%,100%",
]
)
usernames = list()
for user in self.mumble.users.values():
if user["name"] != USER:
usernames.append(user["name"])
title = "<c.system>Recording started with users {users}".format(users=",".join(usernames))
self.captions.add_cue(title, duration=2)

if CREATE_WEBVTT:
self.chapters = webvtt.WebVtt(audio_file_name + "-chapters.vtt")
self.captions = webvtt.WebVtt(
audio_file_name + "-captions.vtt",
regions=[
"Region: id=left width=50% regionanchor=0%,100% viewportanchor=0%,100%",
"Region: id=right width=50% regionanchor=100%,100% viewportanchor=100%,100%",
]
)
usernames = list()
for user in self.mumble.users.values():
if user["name"] != USER:
usernames.append(user["name"])
title = "<c.system>Recording started with users {users}".format(users=",".join(usernames))
self.captions.add_cue(title, duration=2)

if self.cursor_time < time.time() - BUFFER: # it's time to check audio
base_sound = None
Expand All @@ -215,7 +217,7 @@ def loop(self):
user.sound.get_sound(FLOAT_RESOLUTION) # forget about too old sounds

if user.sound.is_sound():
if "caption" not in self.users[session]:
if self.captions is not None and "caption" not in self.users[session]:
self.users[session]["caption"] = self.captions.add_cue("<v {user}>{user}".format(user=user["name"]))

if ( user.sound.first_sound().time >= self.cursor_time and
Expand All @@ -226,7 +228,8 @@ def loop(self):

if sound.target == 0: # take care of the stereo feature
stereo_pcm = audioop.tostereo(sound.pcm, 2, *self.users[session]["stereo"])
self.users[session]["caption"].set_region(self.users[session]["region"])
if self.captions is not None:
self.users[session]["caption"].set_region(self.users[session]["region"])
else:
stereo_pcm = audioop.tostereo(sound.pcm, 2, 1, 1)
if base_sound == None:
Expand All @@ -235,7 +238,7 @@ def loop(self):
#base_sound = audioop.add(base_sound, sound.pcm, 2)
base_sound = self.add_sound(base_sound, stereo_pcm)
else:
if "caption" in self.users[session]:
if self.captions is not None and "caption" in self.users[session]:
self.users[session]["caption"].end()
del self.users[session]["caption"]

Expand Down

0 comments on commit 3026f10

Please sign in to comment.