Update: Refactored the code
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from src.file_manager import FileManager
|
||||
|
||||
|
||||
class FileManagerTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.file_manager = FileManager()
|
||||
self.dir = '<Your file directory>' # replace with your directory
|
||||
|
||||
def test_download_youtube_audio(self):
|
||||
youtube_link = '<Your YouTube link>' # replace with a YouTube link
|
||||
filename = f'{self.dir}/audio.mp4'
|
||||
self.file_manager.download_youtube_audio(youtube_link, filename)
|
||||
self.assertTrue(os.path.exists(filename))
|
||||
os.remove(filename) # clean up after test
|
||||
|
||||
def test_convert_to_wav(self):
|
||||
mp4_file = '<Your mp4 filename>' # replace with an MP4 file in your directory
|
||||
wav_file = mp4_file.replace('.mp4', '.wav')
|
||||
self.file_manager.convert_to_wav(mp4_file, wav_file)
|
||||
self.assertTrue(os.path.exists(wav_file))
|
||||
os.remove(wav_file) # clean up after test
|
||||
|
||||
def test_load_local_file(self):
|
||||
local_file_path = '<Your mp4 filename>' # replace with a file in your directory
|
||||
result_path = self.file_manager.load_local_file(local_file_path)
|
||||
self.assertEqual(result_path, local_file_path.replace('.mp4', '.wav'))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -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()
|
||||
@@ -0,0 +1,19 @@
|
||||
import unittest
|
||||
|
||||
from src.transcript_generator import TranscriptGenerator
|
||||
|
||||
|
||||
class TranscriptGeneratorTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.transcript_generator = TranscriptGenerator()
|
||||
|
||||
def test_generate(self):
|
||||
input_sources = [
|
||||
'https://www.youtube.com/watch?v=BVVo1BaL6JA',
|
||||
'/path/to/your/local/file.mp3'
|
||||
]
|
||||
self.transcript_generator.generate(input_sources)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user