learnable-ai / src /pipeline /speech_processing_pipeline.py
ishworrsubedii's picture
Added new features and improved code formatting:
32a0eda
raw
history blame contribute delete
707 Bytes
"""
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