Update: Refactored the code

This commit is contained in:
Izaya Orihara
2023-10-06 15:28:26 +02:00
parent b43335400d
commit 0b1c24de2a
11 changed files with 265 additions and 60 deletions
+32
View File
@@ -0,0 +1,32 @@
import os
import unittest
from src.transcriber import Transcriber
class TranscriberTest(unittest.TestCase):
def setUp(self):
self.transcriber = Transcriber()
def test_transcribe(self):
wav_file = '<Your wav file>' # Replace with path to a .wav file on your machine
result = self.transcriber.transcribe(wav_file)
self.assertIsNotNone(result)
def test_save_transcript(self):
wav_file = '<Your wav file>' # Replace with path to a .wav file on your machine
result = self.transcriber.transcribe(wav_file)
json_output_file = '<Path to your temporary JSON output file>' # Temporary output file for testing
txt_output_file = '<Path to your temporary TXT output file>' # Temporary output file for testing
self.transcriber.save_transcript(json_output_file, txt_output_file)
self.assertTrue(os.path.exists(json_output_file))
self.assertTrue(os.path.exists(txt_output_file))
os.remove(json_output_file) # clean up after test
os.remove(txt_output_file) # clean up after test
if __name__ == "__main__":
unittest.main()