File size: 2,445 Bytes
32989ce
 
 
200d685
 
 
 
 
 
 
d8bf43a
200d685
32989ce
1c49e44
f259f51
32989ce
200d685
32989ce
 
 
 
1c49e44
 
 
6ab5444
1c49e44
f259f51
200d685
1c49e44
32989ce
 
 
 
 
 
 
 
1c49e44
 
 
 
 
200d685
f259f51
 
 
 
 
 
 
 
 
200d685
d8bf43a
 
 
 
 
f259f51
 
 
 
200d685
d8bf43a
 
 
 
 
 
f259f51
 
 
 
 
 
 
 
1c49e44
5b595ef
 
 
200d685
 
5b595ef
 
32989ce
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
from fastapi import APIRouter


from .Schemas import (
    StatusRequest,
    TTSGenerateRequest,
    HeyGenTTSRequest,
    DescriptRequest,
    DescriptStatusRequest,
    DescriptSfxRequest,
    DescriptTranscript,
)
from .utils.Podcastle import PodcastleAPI
from .utils.HeyGen import HeygenAPI
from .utils.Descript import DescriptTTS
import os
import asyncio

tts_router = APIRouter(tags=["TTS"])
data = {"username": os.environ.get("USERNAME"), "password": os.environ.get("PASSWORD")}
tts = PodcastleAPI(**data)
data = {
    "account": os.environ.get("HEYGEN_USERNAME"),
    "password": os.environ.get("HEYGEN_PASSWORD"),
    "token": os.environ.get("HEYGEN_TOKEN"),
}

descript_tts = DescriptTTS()
heyGentts = HeygenAPI(**data)


@tts_router.post("/generate_tts")
async def generate_voice(req: TTSGenerateRequest):
    print("here --entered!")
    return await tts.make_request(req)


@tts_router.post("/heygen_tts")
async def generate_heygen_voice(req: HeyGenTTSRequest):
    print("hey gen here")
    return await heyGentts.tts_request(req)


@tts_router.post("/descript_tts")
async def generate_descript_voice(req: DescriptRequest):
    return await descript_tts.overdub_text(**req.__dict__)


@tts_router.post("/descript_status")
async def status_descript(req: DescriptStatusRequest):
    return await descript_tts.request_status(req.id)


@tts_router.post("/descript_music")
async def descript_music(req: DescriptSfxRequest):
    return await descript_tts.search_music(req.query)


@tts_router.post("/descript_sfx")
async def descript_sfx(req: DescriptSfxRequest):
    return await descript_tts.search_sound_effects(req.query)


@tts_router.post("/descript_transcript")
async def descript_transcript(req: DescriptTranscript):
    return await descript_tts.get_transcription(req)
    # return await descript_tts.search_sound_effects(req.query)


@tts_router.post("/descript_unsplash")
async def descript_unsplash(req: DescriptSfxRequest):
    return await descript_tts.search_unsplash_images(req.query)


@tts_router.get("/descript_voices")
async def voices_descript():
    return await descript_tts.get_voices()


@tts_router.get("/descript_auto_refresh")
async def auto_refresh():
    asyncio.create_task(descript_tts.start_token_refresh_schedule())
    return {"message": "Token refresh schedule started in the background."}


@tts_router.post("/status")
async def search_id(req: StatusRequest):
    return await tts.check_status(req)