diff --git a/setup.py b/setup.py index c56b025..69cd7d2 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ with open('README_PYPI.md') as file: setup( name="tpro", - version="0.12", + version="0.13", url='https://github.com/zevaverbach/tpro', install_requires=[ 'Click', diff --git a/transcript_processing/converter.py b/transcript_processing/converter.py index 66254cf..4456584 100644 --- a/transcript_processing/converter.py +++ b/transcript_processing/converter.py @@ -33,6 +33,11 @@ class TranscriptConverter: tagged_words ) + @property + @abc.abstractmethod + def transcript_type(self): + pass + @abc.abstractmethod def get_word_objects(self, json_data): pass diff --git a/transcript_processing/converters/amazon.py b/transcript_processing/converters/amazon.py index 55348ed..275a990 100644 --- a/transcript_processing/converters/amazon.py +++ b/transcript_processing/converters/amazon.py @@ -9,6 +9,7 @@ from .. import helpers class AmazonConverter(TranscriptConverter): name = 'amazon' + transcript_type = dict def __init__(self, json_data): super().__init__(json_data) diff --git a/transcript_processing/converters/gentle.py b/transcript_processing/converters/gentle.py index 2d4defc..f6a0016 100644 --- a/transcript_processing/converters/gentle.py +++ b/transcript_processing/converters/gentle.py @@ -6,6 +6,7 @@ from ..converter import TranscriptConverter class GentleConverter(TranscriptConverter): name = 'gentle' + transcript_type = dict def __init__(self, json_data): super().__init__(json_data) diff --git a/transcript_processing/converters/google.py b/transcript_processing/converters/google.py index 8a8d262..d85f6d3 100644 --- a/transcript_processing/converters/google.py +++ b/transcript_processing/converters/google.py @@ -8,6 +8,8 @@ from .. import helpers class GoogleConverter(TranscriptConverter): + transcript_type = str + def __init__(self, transcript_data: str): super().__init__(transcript_data) self.json_data = self.pre_process(transcript_data) diff --git a/transcript_processing/converters/speechmatics.py b/transcript_processing/converters/speechmatics.py index 37204b5..b63a0f8 100644 --- a/transcript_processing/converters/speechmatics.py +++ b/transcript_processing/converters/speechmatics.py @@ -9,6 +9,7 @@ from .. import helpers class SpeechmaticsConverter(TranscriptConverter): name = 'speechmatics' + transcript_type = dict def __init__(self, path): super().__init__(path) diff --git a/transcript_processing/outputs.py b/transcript_processing/outputs.py index 5c76ac0..d435f8e 100644 --- a/transcript_processing/outputs.py +++ b/transcript_processing/outputs.py @@ -10,7 +10,7 @@ def vo(self): if word['always_capitalized']: word_word = word['word'].title() else: - word_word['word'] + word_word = word['word'] transcript.append({ 'start': word['start'], diff --git a/transcript_processing/tpro.py b/transcript_processing/tpro.py index 59e1d11..cc32867 100644 --- a/transcript_processing/tpro.py +++ b/transcript_processing/tpro.py @@ -23,10 +23,15 @@ def cli(print_output, input_format, output_format): - json_data = json.load(transcript_data_path) - service = services[input_format] + transcript_data_file_handle = transcript_data_path - converter = service(json_data) + service = services[input_format] + if service.transcript_type == dict: + transcript_data = json.load(transcript_data_file_handle) + else: + transcript_data = transcript_data_file_handle.read() + + converter = service(transcript_data) converter.convert() converter.save(output_path, output_format)