tested elevenlabs transcript working
Browse files
App/Generate/database/ElevenLab.py
CHANGED
|
@@ -9,6 +9,7 @@ class ElevenLab:
|
|
| 9 |
def __init__(self):
|
| 10 |
self.api_url = "https://4336zvnmaw.us-east-1.awsapprunner.com"
|
| 11 |
self.dir = str(tempfile.mkdtemp())
|
|
|
|
| 12 |
self.headers = {"Connection": "keep-alive", "Content-Type": "application/json"}
|
| 13 |
self.voices = [
|
| 14 |
{
|
|
@@ -741,11 +742,21 @@ class ElevenLab:
|
|
| 741 |
},
|
| 742 |
]
|
| 743 |
|
| 744 |
-
async def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 745 |
async with aiohttp.ClientSession() as session:
|
| 746 |
-
|
| 747 |
-
f"{
|
| 748 |
-
|
|
|
|
|
|
|
| 749 |
return await response.json()
|
| 750 |
|
| 751 |
async def say(self, text, speaker="Adam"):
|
|
@@ -757,7 +768,6 @@ class ElevenLab:
|
|
| 757 |
data = {"voiceId": voiceId, "text": text}
|
| 758 |
|
| 759 |
response_data = await self._make_request("post", "convert", json=data)
|
| 760 |
-
print(response_data)
|
| 761 |
audio_url = response_data["contentUrl"]
|
| 762 |
temp = await self.download_file(audio_url)
|
| 763 |
return audio_url, temp
|
|
@@ -779,11 +789,17 @@ class ElevenLab:
|
|
| 779 |
return save_path
|
| 780 |
|
| 781 |
|
| 782 |
-
# Usage
|
| 783 |
# async def main():
|
| 784 |
# tts = ElevenLab()
|
| 785 |
-
# await tts.say(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 786 |
|
| 787 |
|
| 788 |
-
# Run the main function
|
| 789 |
# asyncio.run(main())
|
|
|
|
| 9 |
def __init__(self):
|
| 10 |
self.api_url = "https://4336zvnmaw.us-east-1.awsapprunner.com"
|
| 11 |
self.dir = str(tempfile.mkdtemp())
|
| 12 |
+
self.descript = "https://yakova-embedding.hf.space"
|
| 13 |
self.headers = {"Connection": "keep-alive", "Content-Type": "application/json"}
|
| 14 |
self.voices = [
|
| 15 |
{
|
|
|
|
| 742 |
},
|
| 743 |
]
|
| 744 |
|
| 745 |
+
async def _make_transcript(self, links, text):
|
| 746 |
+
|
| 747 |
+
data = {"audio_url": links, "text": text, "file_extenstion": ".mp3"}
|
| 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:
|
| 756 |
+
url = f"{external}/{endpoint}"
|
| 757 |
+
else:
|
| 758 |
+
url = f"{self.api_url}/{endpoint}"
|
| 759 |
+
async with getattr(session, method)(url=url, json=json) as response:
|
| 760 |
return await response.json()
|
| 761 |
|
| 762 |
async def say(self, text, speaker="Adam"):
|
|
|
|
| 768 |
data = {"voiceId": voiceId, "text": text}
|
| 769 |
|
| 770 |
response_data = await self._make_request("post", "convert", json=data)
|
|
|
|
| 771 |
audio_url = response_data["contentUrl"]
|
| 772 |
temp = await self.download_file(audio_url)
|
| 773 |
return audio_url, temp
|
|
|
|
| 789 |
return save_path
|
| 790 |
|
| 791 |
|
| 792 |
+
# # Usage
|
| 793 |
# async def main():
|
| 794 |
# tts = ElevenLab()
|
| 795 |
+
# url, temp = await tts.say(
|
| 796 |
+
# "Did you know that you don't have the balls to talk to me"
|
| 797 |
+
# )
|
| 798 |
+
# tranny = await tts._make_transcript(
|
| 799 |
+
# links=[url], text="Did you know that you don't have the balls to talk to me"
|
| 800 |
+
# )
|
| 801 |
+
# print(tranny)
|
| 802 |
|
| 803 |
|
| 804 |
+
# # Run the main function
|
| 805 |
# asyncio.run(main())
|
App/Generate/database/Model.py
CHANGED
|
@@ -160,8 +160,8 @@ class Project(orm.Model):
|
|
| 160 |
|
| 161 |
|
| 162 |
class Scene(orm.Model):
|
| 163 |
-
tts =
|
| 164 |
-
eleven = ElevenLab()
|
| 165 |
tablename = "scenes"
|
| 166 |
registry = models
|
| 167 |
fields = {
|
|
@@ -201,7 +201,7 @@ class Scene(orm.Model):
|
|
| 201 |
retry_count = 0
|
| 202 |
while retry_count < 3:
|
| 203 |
try:
|
| 204 |
-
return await self.
|
| 205 |
text=self.narration + " master"
|
| 206 |
) ### The blanks help to even stuff up.
|
| 207 |
except Exception as e:
|
|
|
|
| 160 |
|
| 161 |
|
| 162 |
class Scene(orm.Model):
|
| 163 |
+
tts = ElevenLab()
|
| 164 |
+
# eleven = ElevenLab()
|
| 165 |
tablename = "scenes"
|
| 166 |
registry = models
|
| 167 |
fields = {
|
|
|
|
| 201 |
retry_count = 0
|
| 202 |
while retry_count < 3:
|
| 203 |
try:
|
| 204 |
+
return await self.tts.say(
|
| 205 |
text=self.narration + " master"
|
| 206 |
) ### The blanks help to even stuff up.
|
| 207 |
except Exception as e:
|