added end word
Browse files- App/Generate/database/Model.py +10 -23
App/Generate/database/Model.py
CHANGED
|
@@ -90,24 +90,25 @@ class Project(orm.Model):
|
|
| 90 |
self.duration += scene.narration_duration ## added one for spaces
|
| 91 |
self.links.append({"file_name": file_name, "link": scene.narration_link})
|
| 92 |
|
| 93 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
audio_assets.append(
|
| 95 |
{
|
| 96 |
"type": "audio",
|
| 97 |
"name": file_name,
|
| 98 |
"start": self.start,
|
| 99 |
-
"end":
|
| 100 |
"props": {
|
| 101 |
-
|
| 102 |
-
|
| 103 |
# "volume": 5,
|
| 104 |
},
|
| 105 |
}
|
| 106 |
)
|
| 107 |
-
|
| 108 |
-
# generate transcripts
|
| 109 |
-
temp = await scene.generate_scene_transcript(offset=self.start)
|
| 110 |
-
text_stream.extend(temp)
|
| 111 |
|
| 112 |
## images and transitions
|
| 113 |
for image in scene.images:
|
|
@@ -154,20 +155,6 @@ class Project(orm.Model):
|
|
| 154 |
await self.update(**self.__dict__)
|
| 155 |
return {"links": self.links, "assets": self.assets, "constants": self.constants}
|
| 156 |
|
| 157 |
-
async def generate_transcript(self):
|
| 158 |
-
project_scenes: List[Scene] = await self.get_all_scenes()
|
| 159 |
-
links = []
|
| 160 |
-
text = ""
|
| 161 |
-
for narration in project_scenes:
|
| 162 |
-
narration: Scene
|
| 163 |
-
|
| 164 |
-
text += " " + narration.narration
|
| 165 |
-
links.append(narration.narration_link)
|
| 166 |
-
|
| 167 |
-
transcript = await narration.tts._make_transcript(links=links, text=text)
|
| 168 |
-
# transcript = transform_alignment_data(transcript)
|
| 169 |
-
return transcript
|
| 170 |
-
|
| 171 |
|
| 172 |
class Scene(orm.Model):
|
| 173 |
tts = Speak()
|
|
@@ -211,7 +198,7 @@ class Scene(orm.Model):
|
|
| 211 |
while retry_count < 3:
|
| 212 |
try:
|
| 213 |
return await self.tts.say(
|
| 214 |
-
text=self.narration + "
|
| 215 |
) ### The blanks help to even stuff up.
|
| 216 |
except Exception as e:
|
| 217 |
print(f"Failed to generate narration: {e}")
|
|
|
|
| 90 |
self.duration += scene.narration_duration ## added one for spaces
|
| 91 |
self.links.append({"file_name": file_name, "link": scene.narration_link})
|
| 92 |
|
| 93 |
+
# generate transcripts
|
| 94 |
+
temp = await scene.generate_scene_transcript(offset=self.start)
|
| 95 |
+
end_word = temp[-1]
|
| 96 |
+
|
| 97 |
+
# narration of the story
|
| 98 |
audio_assets.append(
|
| 99 |
{
|
| 100 |
"type": "audio",
|
| 101 |
"name": file_name,
|
| 102 |
"start": self.start,
|
| 103 |
+
"end": end_word["start"],
|
| 104 |
"props": {
|
| 105 |
+
"startFrom": 0,
|
| 106 |
+
"endAt": end_word["start"] * 30,
|
| 107 |
# "volume": 5,
|
| 108 |
},
|
| 109 |
}
|
| 110 |
)
|
| 111 |
+
text_stream.extend(temp[:-1])
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
## images and transitions
|
| 114 |
for image in scene.images:
|
|
|
|
| 155 |
await self.update(**self.__dict__)
|
| 156 |
return {"links": self.links, "assets": self.assets, "constants": self.constants}
|
| 157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
class Scene(orm.Model):
|
| 160 |
tts = Speak()
|
|
|
|
| 198 |
while retry_count < 3:
|
| 199 |
try:
|
| 200 |
return await self.tts.say(
|
| 201 |
+
text=self.narration + "master"
|
| 202 |
) ### The blanks help to even stuff up.
|
| 203 |
except Exception as e:
|
| 204 |
print(f"Failed to generate narration: {e}")
|