File size: 1,046 Bytes
1d427a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st

from src.parser import read_epub, read_txt
from src.predict import audiobook_gen, load_models
from src.output import assemble_zip

st.title('Audiobook Generation Tool')
st.markdown("This tool generates audiobook files from an imported ebook file.")

with st.sidebar:
    ebook_upload = st.file_uploader(
        label = "Upload the target ebook (.epub only)",
        type = ['epub'])

if st.button('Click to run!'):
    ebook, title = read_epub(ebook_upload)
    model = load_models()
    st.success('Parsing complete!')

    with st.spinner('Generating audio...'):
        audiobook_gen(ebook, title, model)
    st.success('TTS generation complete!')

    with st.spinner('Building zip file...'):
        zip_file = assemble_zip(title)
        title_name = f'{title}.zip'
    st.success('Zip file prepared!')

    with open(zip_file, "rb") as fp:
        btn = st.download_button(
            label="Download Audiobook",
            data=fp,
            file_name=title_name,
            mime="application/zip"
        )