Skip to content

Commit

Permalink
Implemented presenter for FAB Live BCAST
Browse files Browse the repository at this point in the history
  • Loading branch information
alumae committed Dec 8, 2021
1 parent 4674a1d commit bcae58c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ It consists of the following components:
* Words-to-numbers converter (FST-based, using Pynini)

## News
* 2021-12-08: implemented presenter for FAB Subtitler BCAST

* 2021-12-06: language ID check is done after 3 seconds of speech; if a non-target language is detected,
another check is done after 5 seconds (new). This is to filter out false negatives when an utterance starts with
Expand Down
3 changes: 3 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def main(args):
presenter = YoutubeLivePresenter(captions_url=args.youtube_caption_url)
elif args.fab_speechinterface_url is not None:
presenter = FabLiveWordByWordPresenter(fab_speech_iterface_url=args.fab_speechinterface_url)
elif args.fab_bcast_url is not None:
presenter = FabBcastWordByWordPresenter(fab_bcast_url=args.fab_bcast_url)
elif args.zoom_caption_url is not None:
presenter = ZoomPresenter(captions_url=args.zoom_caption_url)
else:
Expand Down Expand Up @@ -101,6 +103,7 @@ def main(args):
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('--youtube-caption-url', type=str)
parser.add_argument('--fab-speechinterface-url', type=str)
parser.add_argument('--fab-bcast-url', type=str)
parser.add_argument('--zoom-caption-url', type=str)
parser.add_argument('--word-output-file', type=argparse.FileType('w'), default=sys.stdout)
parser.add_argument('input_file')
Expand Down
26 changes: 23 additions & 3 deletions presenters.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,16 @@ def _send_final(self):


class FabLiveWordByWordPresenter(AbstractWordByWordPresenter):
def __init__(self, fab_speech_iterface_url):
def __init__(self, fab_speech_interface_url):
super().__init__()
self.fab_speech_iterface_url = fab_speech_iterface_url
self.fab_speech_interface_url = fab_speech_interface_url

def _send_word(self, word):
logging.info("Sending captions to FAB")
text = word["word"]
if self.num_sent_words > 0:
text = " " + text
resp = requests.get(url=self.fab_speech_iterface_url, params={"text": text})
resp = requests.get(url=self.fab_speech_interface_url, params={"text": text})
logging.info(f"Response status {resp.status_code} {resp.reason}: {resp.text}")


Expand All @@ -226,6 +226,26 @@ def _send_final(self):
#self._send_word("{SEND}")


class FabBcastWordByWordPresenter(AbstractWordByWordPresenter):
def __init__(self, fab_bcast_url):
super().__init__()
self.fab_bcast_url = fab_bcast_url
resp = requests.get(url=f"{self.fab_bcast_url}/start")
logging.info(f"Response status {resp.status_code} {resp.reason}: {resp.text}")

def _send_word(self, word):
logging.info("Sending captions to FAB Subtitler BCAST")
text = word["word"]
if self.num_sent_words > 0:
text = " " + text
resp = requests.get(url=f"{self.fab_bcast_url}/send", params={"text": text})
logging.info(f"Response status {resp.status_code} {resp.reason}: {resp.text}")

def _send_final(self):
pass
#self._send_word("{SEND}")


class ZoomPresenter(AbstractWordByWordPresenter):

def __init__(self, captions_url):
Expand Down

0 comments on commit bcae58c

Please sign in to comment.