How to use delete_language_model method in localstack

Best Python code snippet using localstack_python

test_speech_to_text_v1.py

Source:test_speech_to_text_v1.py Github

copy

Full Screen

...25 base_model_name="en-US_BroadbandModel").get_result()26 cls.customization_id = cls.create_custom_model.get('customization_id')27 @classmethod28 def teardown_class(cls):29 cls.speech_to_text.delete_language_model(30 customization_id=cls.create_custom_model.get('customization_id'))31 def test_models(self):32 output = self.speech_to_text.list_models().get_result()33 assert output is not None34 model = self.speech_to_text.get_model(35 'ko-KR_BroadbandModel').get_result()36 assert model is not None37 try:38 self.speech_to_text.get_model('bogus')39 except Exception as e:40 assert 'X-global-transaction-id:' in str(e)41 def test_create_custom_model(self):42 current_custom_models = self.speech_to_text.list_language_models(43 ).get_result()44 assert len(current_custom_models['customizations']) - len(45 self.custom_models.get('customizations')) >= 146 def test_recognize(self):47 with open(48 os.path.join(os.path.dirname(__file__),49 '../../resources/speech.wav'), 'rb') as audio_file:50 output = self.speech_to_text.recognize(51 audio=audio_file,52 content_type='audio/l16; rate=44100').get_result()53 assert output['results'][0]['alternatives'][0][54 'transcript'] == 'thunderstorms could produce large hail isolated tornadoes and heavy rain '55 def test_recognitions(self):56 output = self.speech_to_text.check_jobs().get_result()57 assert output is not None58 def test_custom_corpora(self):59 output = self.speech_to_text.list_corpora(60 self.customization_id).get_result()61 assert not output['corpora']62 def test_acoustic_model(self):63 list_models = self.speech_to_text.list_acoustic_models().get_result()64 assert list_models is not None65 create_acoustic_model = self.speech_to_text.create_acoustic_model(66 name="integration_test_model_python",67 base_model_name="en-US_BroadbandModel").get_result()68 assert create_acoustic_model is not None69 get_acoustic_model = self.speech_to_text.get_acoustic_model(70 create_acoustic_model['customization_id']).get_result()71 assert get_acoustic_model is not None72 self.speech_to_text.reset_acoustic_model(73 get_acoustic_model['customization_id']).get_result()74 self.speech_to_text.delete_acoustic_model(75 get_acoustic_model['customization_id']).get_result()76 def test_recognize_using_websocket(self):77 class MyRecognizeCallback(RecognizeCallback):78 def __init__(self):79 RecognizeCallback.__init__(self)80 self.error = None81 self.transcript = None82 def on_error(self, error):83 self.error = error84 def on_transcription(self, transcript):85 self.transcript = transcript86 test_callback = MyRecognizeCallback()87 with open(88 os.path.join(os.path.dirname(__file__),89 '../../resources/speech.wav'), 'rb') as audio_file:90 audio_source = AudioSource(audio_file, False)91 t = threading.Thread(92 target=self.speech_to_text.recognize_using_websocket,93 args=(audio_source, "audio/l16; rate=44100", test_callback))94 t.start()95 t.join()96 assert test_callback.error is None97 assert test_callback.transcript is not None98 assert test_callback.transcript[0][99 'transcript'] == 'thunderstorms could produce large hail isolated tornadoes and heavy rain '100 def test_custom_grammars(self):101 customization_id = None102 for custom_model in self.custom_models.get('customizations'):103 if custom_model['name'] == 'integration_test_model_for_grammar':104 customization_id = custom_model['customization_id']105 break106 if customization_id is None:107 print('Creating a new custom model')108 create_custom_model_for_grammar = self.speech_to_text.create_language_model(109 name="integration_test_model_for_grammar",110 base_model_name="en-US_BroadbandModel").get_result()111 customization_id = create_custom_model_for_grammar[112 'customization_id']113 grammars = self.speech_to_text.list_grammars(114 customization_id).get_result()['grammars']115 if not grammars:116 with open(117 os.path.join(os.path.dirname(__file__),118 '../../resources/confirm-grammar.xml'),119 'rb') as grammar_file:120 add_grammar_result = self.speech_to_text.add_grammar(121 customization_id,122 grammar_name='test-add-grammar-python',123 grammar_file=grammar_file,124 content_type='application/srgs+xml',125 allow_overwrite=True).get_result()126 assert add_grammar_result is not None127 get_grammar_result = self.speech_to_text.get_grammar(128 customization_id,129 grammar_name='test-add-grammar-python').get_result()130 assert get_grammar_result is not None131 else:132 print('Deleting grammar')133 try:134 self.speech_to_text.delete_grammar(135 customization_id, 'test-add-grammar-python').get_result()136 except ibm_watson.ApiException as ex:137 print('Could not delete grammar: {0}'.format(ex.message))138 try:139 self.speech_to_text.delete_language_model(customization_id)140 except ibm_watson.ApiException as ex:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful