File size: 707 Bytes
32a0eda
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""
Created By: ishwor subedi
Date: 2024-08-13
"""

from src.services.speech.speech_to_text import SpeechToText
from src.services.speech.text_to_speech import TextToSpeech


class SpeechTranscriptionPipeline:
    def __init__(self):
        self.speech_to_text_ = SpeechToText()
        self.text_to_speech_ = TextToSpeech()

    def text_to_speech(self, text: str, lang: str, tld: str) -> str:
        base64_audio = self.text_to_speech_.sentence_audio_generator(text, lang, tld)

        yield base64_audio

    def speech_to_text(self, audio, lang: str) -> str:
        transcript_with_timestamp, transcript = self.speech_to_text_.transcribe_audio(audio=audio, language=lang, )
        return transcript