File size: 1,342 Bytes
ffd4428
 
 
d2b35f2
 
50c1ae1
 
ffd4428
d2b35f2
 
 
 
ffd4428
 
d2b35f2
 
ffd4428
d2b35f2
ffd4428
d2b35f2
 
 
ebd8530
993705a
ebd8530
3319852
577ffe8
ebd8530
76d8852
 
ebd8530
e119c7e
 
 
 
 
 
 
ebd8530
 
 
 
e119c7e
ebd8530
 
 
 
 
 
 
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
import streamlit as st
from transformers import pipeline

# function part
# Toxicity Analysis
    pipe = pipeline("text-classification", model="Matt09Miao/GP5_tweet_toxic")    
    Toxic_model = pipe
   

# text2story
def text2story(text):
    pipe = pipeline("text-generation", model="pranavpsv/genre-story-generator-v2")
    tweet_text_text = pipe(text)[0]['generated_text']
    return tweet_text

# text2audio
def text2audio(toxic_result):
    pipe = pipeline("text-to-audio", model="Matthijs/mms-tts-eng")
    audio_data = pipe(toxic_result)
    return audio_data



st.set_page_config(page_title="Generate Your Tweet and Toxicity Analysis")

st.header("Please input your first word of a Tweet :performing_arts:")
input = st.text_input("In put your first word...")

if input is None:
    print("Your word is welcome :slightly_smiling_face:")

    #Stage 1: Input to Tweet
    st.text('Generating a Tweet...')
    tweet = text2story(input)
    st.write(tweet)

    #Stage 2: Tweet Toxicity Analysis
    


    #Stage 3: Story to Audio data
    st.text('Generating audio data...')
    audio_data =text2audio(tweet)

    # Play button
    if st.button("Play Audio"):
        st.audio(audio_data['audio'],
                    format="audio/wav",
                    start_time=0,
                    sample_rate = audio_data['sampling_rate'])