fixed bug in cli that didn't handle txt files (from google)
This commit is contained in:
2
setup.py
2
setup.py
@@ -6,7 +6,7 @@ with open('README_PYPI.md') as file:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="tpro",
|
name="tpro",
|
||||||
version="0.12",
|
version="0.13",
|
||||||
url='https://github.com/zevaverbach/tpro',
|
url='https://github.com/zevaverbach/tpro',
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'Click',
|
'Click',
|
||||||
|
|||||||
@@ -33,6 +33,11 @@ class TranscriptConverter:
|
|||||||
tagged_words
|
tagged_words
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
@abc.abstractmethod
|
||||||
|
def transcript_type(self):
|
||||||
|
pass
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_word_objects(self, json_data):
|
def get_word_objects(self, json_data):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from .. import helpers
|
|||||||
class AmazonConverter(TranscriptConverter):
|
class AmazonConverter(TranscriptConverter):
|
||||||
|
|
||||||
name = 'amazon'
|
name = 'amazon'
|
||||||
|
transcript_type = dict
|
||||||
|
|
||||||
def __init__(self, json_data):
|
def __init__(self, json_data):
|
||||||
super().__init__(json_data)
|
super().__init__(json_data)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from ..converter import TranscriptConverter
|
|||||||
class GentleConverter(TranscriptConverter):
|
class GentleConverter(TranscriptConverter):
|
||||||
|
|
||||||
name = 'gentle'
|
name = 'gentle'
|
||||||
|
transcript_type = dict
|
||||||
|
|
||||||
def __init__(self, json_data):
|
def __init__(self, json_data):
|
||||||
super().__init__(json_data)
|
super().__init__(json_data)
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ from .. import helpers
|
|||||||
|
|
||||||
class GoogleConverter(TranscriptConverter):
|
class GoogleConverter(TranscriptConverter):
|
||||||
|
|
||||||
|
transcript_type = str
|
||||||
|
|
||||||
def __init__(self, transcript_data: str):
|
def __init__(self, transcript_data: str):
|
||||||
super().__init__(transcript_data)
|
super().__init__(transcript_data)
|
||||||
self.json_data = self.pre_process(transcript_data)
|
self.json_data = self.pre_process(transcript_data)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from .. import helpers
|
|||||||
class SpeechmaticsConverter(TranscriptConverter):
|
class SpeechmaticsConverter(TranscriptConverter):
|
||||||
|
|
||||||
name = 'speechmatics'
|
name = 'speechmatics'
|
||||||
|
transcript_type = dict
|
||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
super().__init__(path)
|
super().__init__(path)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ def vo(self):
|
|||||||
if word['always_capitalized']:
|
if word['always_capitalized']:
|
||||||
word_word = word['word'].title()
|
word_word = word['word'].title()
|
||||||
else:
|
else:
|
||||||
word_word['word']
|
word_word = word['word']
|
||||||
|
|
||||||
transcript.append({
|
transcript.append({
|
||||||
'start': word['start'],
|
'start': word['start'],
|
||||||
|
|||||||
@@ -23,10 +23,15 @@ def cli(print_output,
|
|||||||
input_format,
|
input_format,
|
||||||
output_format):
|
output_format):
|
||||||
|
|
||||||
json_data = json.load(transcript_data_path)
|
transcript_data_file_handle = transcript_data_path
|
||||||
service = services[input_format]
|
|
||||||
|
|
||||||
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.convert()
|
||||||
converter.save(output_path, output_format)
|
converter.save(output_path, output_format)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user