Mbonea commited on
Commit
39b6e54
·
1 Parent(s): 81d2d06
Files changed (1) hide show
  1. App/Generate/database/ElevenLab.py +22 -2
App/Generate/database/ElevenLab.py CHANGED
@@ -748,8 +748,29 @@ class ElevenLab:
748
  response_data = await self._make_request(
749
  "post", "descript_transcript", json=data, external=self.descript
750
  )
 
 
 
 
 
 
751
  return response_data
752
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
753
  async def _make_request(self, method, endpoint, json=None, external=None):
754
  async with aiohttp.ClientSession() as session:
755
  if external:
@@ -757,8 +778,6 @@ class ElevenLab:
757
  else:
758
  url = f"{self.api_url}/{endpoint}"
759
  async with getattr(session, method)(url=url, json=json) as response:
760
- temp=await response.text()
761
- print(temp)
762
  return await response.json()
763
 
764
  async def say(self, text, speaker="Adam"):
@@ -767,6 +786,7 @@ class ElevenLab:
767
  name = i["name"].split(" ")[0]
768
  if name.lower() == speaker.lower():
769
  voiceId = i["voice_id"]
 
770
  data = {"voiceId": voiceId, "text": text}
771
 
772
  response_data = await self._make_request("post", "convert", json=data)
 
748
  response_data = await self._make_request(
749
  "post", "descript_transcript", json=data, external=self.descript
750
  )
751
+ if not response_data:
752
+ response_data = await self.aligner(
753
+ "post",
754
+ "align/url",
755
+ json=data,
756
+ )
757
  return response_data
758
 
759
+ async def aligner(
760
+ self,
761
+ method,
762
+ endpoint,
763
+ json=None,
764
+ external="https://yakova-aligner.hf.space/",
765
+ ):
766
+ async with aiohttp.ClientSession() as session:
767
+ if external:
768
+ url = f"{external}"
769
+ else:
770
+ url = f"{self.api_url}/{endpoint}"
771
+ async with getattr(session, method)(url=url, json=json) as response:
772
+ return await response.json()
773
+
774
  async def _make_request(self, method, endpoint, json=None, external=None):
775
  async with aiohttp.ClientSession() as session:
776
  if external:
 
778
  else:
779
  url = f"{self.api_url}/{endpoint}"
780
  async with getattr(session, method)(url=url, json=json) as response:
 
 
781
  return await response.json()
782
 
783
  async def say(self, text, speaker="Adam"):
 
786
  name = i["name"].split(" ")[0]
787
  if name.lower() == speaker.lower():
788
  voiceId = i["voice_id"]
789
+ # voiceId = "yl2ZDV1MzN4HbQJbMihG"
790
  data = {"voiceId": voiceId, "text": text}
791
 
792
  response_data = await self._make_request("post", "convert", json=data)