Avatar's can't be random on the video endpoint since these will be called in batch

This commit is contained in:
Carlos-Mesquita
2024-11-09 10:33:05 +00:00
parent e955a16abf
commit cf1b676312
4 changed files with 4 additions and 19 deletions

View File

@@ -16,7 +16,7 @@ speaking_router = APIRouter()
class Video(BaseModel): class Video(BaseModel):
text: str text: str
avatar: Optional[str] = None avatar: str
@speaking_router.post( @speaking_router.post(
'/media', '/media',
@@ -75,13 +75,3 @@ async def get_speaking_task(
second_topic = second_topic if second_topic else random.choice(EducationalContent.MTI_TOPICS) second_topic = second_topic if second_topic else random.choice(EducationalContent.MTI_TOPICS)
return await speaking_controller.get_speaking_part(task, topic_or_first_topic, second_topic, difficulty) return await speaking_controller.get_speaking_part(task, topic_or_first_topic, second_topic, difficulty)
"""
async def generate_video(self, text: str, avatar: str):
return await self._vid_gen.create_video(text, avatar)
async def pool_video(self, vid_id: str):
return await self._vid_gen.pool_status(vid_id)
"""

View File

@@ -15,7 +15,7 @@ class ISpeakingController(ABC):
pass pass
@abstractmethod @abstractmethod
async def generate_video(self, text: str, avatar: Optional[str]): async def generate_video(self, text: str, avatar: str):
pass pass
@abstractmethod @abstractmethod

View File

@@ -19,7 +19,7 @@ class SpeakingController(ISpeakingController):
async def get_avatars(self): async def get_avatars(self):
return await self._vid_gen.get_avatars() return await self._vid_gen.get_avatars()
async def generate_video(self, text: str, avatar: Optional[str]): async def generate_video(self, text: str, avatar: str):
return await self._vid_gen.create_video(text, avatar) return await self._vid_gen.create_video(text, avatar)
async def pool_video(self, vid_id: str): async def pool_video(self, vid_id: str):

View File

@@ -29,12 +29,7 @@ class Heygen(IVideoGeneratorService):
self._logger = logging.getLogger(__name__) self._logger = logging.getLogger(__name__)
async def create_video(self, text: str, avatar: str): async def create_video(self, text: str, avatar: str):
if not avatar: avatar = self._avatars[avatar]["id"]
random_avatar_name = random.choice(list(self._avatars.keys()))
avatar = self._avatars[random_avatar_name]["id"]
#["id"]
else:
avatar = self._avatars[avatar]["id"]
create_video_url = f'https://api.heygen.com/v2/template/{avatar}/generate' create_video_url = f'https://api.heygen.com/v2/template/{avatar}/generate'
data = { data = {