Merged in release/async (pull request #37)
Remove unnecessary section id's from reading and listening to retrieve questions since context is already on the post dto Approved-by: Tiago Ribeiro
This commit is contained in:
@@ -52,13 +52,12 @@ async def generate_mp3(
|
||||
|
||||
|
||||
@listening_router.post(
|
||||
'/{section}',
|
||||
'/',
|
||||
dependencies=[Depends(Authorized([IsAuthenticatedViaBearerToken]))]
|
||||
)
|
||||
@inject
|
||||
async def generate_listening_exercise(
|
||||
dto: GenerateListeningExercises,
|
||||
section: int = Path(..., ge=1, le=4),
|
||||
listening_controller: IListeningController = Depends(Provide[controller])
|
||||
):
|
||||
return await listening_controller.get_listening_question(section, dto)
|
||||
return await listening_controller.get_listening_question(dto)
|
||||
|
||||
@@ -40,13 +40,12 @@ async def generate_passage(
|
||||
return await reading_controller.generate_reading_passage(passage, topic, word_count)
|
||||
|
||||
@reading_router.post(
|
||||
'/{passage}',
|
||||
'/',
|
||||
dependencies=[Depends(Authorized([IsAuthenticatedViaBearerToken]))]
|
||||
)
|
||||
@inject
|
||||
async def generate_reading(
|
||||
dto: ReadingDTO,
|
||||
passage: int = Path(..., ge=1, le=3),
|
||||
reading_controller: IReadingController = Depends(Provide[controller])
|
||||
):
|
||||
return await reading_controller.generate_reading_exercises(passage, dto)
|
||||
return await reading_controller.generate_reading_exercises(dto)
|
||||
|
||||
@@ -14,7 +14,7 @@ class IListeningController(ABC):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
async def get_listening_question(self, section: int, dto):
|
||||
async def get_listening_question(self, dto):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
|
||||
@@ -15,6 +15,6 @@ class IReadingController(ABC):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
async def generate_reading_exercises(self, passage: int, dto):
|
||||
async def generate_reading_exercises(self, dto):
|
||||
pass
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ class ListeningController(IListeningController):
|
||||
async def generate_listening_dialog(self, section_id: int, topic: str, difficulty: str):
|
||||
return await self._service.generate_listening_dialog(section_id, topic, difficulty)
|
||||
|
||||
async def get_listening_question(self, section: int, dto: GenerateListeningExercises):
|
||||
return await self._service.get_listening_question(section, dto)
|
||||
async def get_listening_question(self, dto: GenerateListeningExercises):
|
||||
return await self._service.get_listening_question(dto)
|
||||
|
||||
async def generate_mp3(self, dto: Dialog):
|
||||
mp3 = await self._service.generate_mp3(dto)
|
||||
|
||||
@@ -24,5 +24,5 @@ class ReadingController(IReadingController):
|
||||
async def generate_reading_passage(self, passage: int, topic: Optional[str], word_count: Optional[int]):
|
||||
return await self._service.generate_reading_passage(passage, topic, word_count)
|
||||
|
||||
async def generate_reading_exercises(self, passage: int, dto: ReadingDTO):
|
||||
async def generate_reading_exercises(self, dto: ReadingDTO):
|
||||
return await self._service.generate_reading_exercises(dto)
|
||||
|
||||
@@ -13,7 +13,7 @@ class IListeningService(ABC):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
async def get_listening_question(self, section: int, dto):
|
||||
async def get_listening_question(self, dto):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
|
||||
@@ -92,6 +92,7 @@ class ListeningService(IListeningService):
|
||||
async def generate_listening_dialog(self, section: int, topic: str, difficulty: str):
|
||||
return await self._sections[f'section_{section}']["generate_dialogue"](section, topic)
|
||||
|
||||
# TODO: When mp3 editor
|
||||
async def get_dialog_from_audio(self, upload: UploadFile):
|
||||
ext, path_id = await FileHelper.save_upload(upload)
|
||||
dialog = await self._stt.speech_to_text(f'./tmp/{path_id}/upload.{ext}')
|
||||
@@ -100,8 +101,7 @@ class ListeningService(IListeningService):
|
||||
async def generate_mp3(self, dto: Dialog) -> bytes:
|
||||
return await self._tts.text_to_speech(dto)
|
||||
|
||||
async def get_listening_question(self, section: int, dto: GenerateListeningExercises):
|
||||
dialog_type = self._sections[f'section_{section}']["type"]
|
||||
async def get_listening_question(self, dto: GenerateListeningExercises):
|
||||
start_id = 1
|
||||
exercise_tasks = []
|
||||
|
||||
@@ -109,7 +109,7 @@ class ListeningService(IListeningService):
|
||||
exercise_tasks.append(
|
||||
self._generate_exercise(
|
||||
req_exercise,
|
||||
dialog_type,
|
||||
"dialog or monologue",
|
||||
dto.text,
|
||||
start_id,
|
||||
dto.difficulty
|
||||
|
||||
Reference in New Issue
Block a user