Files
project_whispertrans_code/tests/test_transcriber.py
T

33 lines
1.1 KiB
Python

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()