File size: 1,094 Bytes
ffd4428
335f18b
 
ffd4428
 
335f18b
a5643e3
03272c6
 
 
 
fa0b08d
35f5bf3
ebd8530
03272c6
35f5bf3
 
a716b14
6fa920b
 
ffe91fc
 
787f0bf
c1c94b8
 
2024f9a
 
 
 
c1c94b8
 
2024f9a
 
 
 
0e7be6c
fa0b08d
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
import streamlit as st

# Use a pipeline as a high-level helper
from transformers import pipeline

toxic_model = pipeline("text-classification", model="Matt09Miao/GP5_tweet_toxic")  
    
def text2audio(text):
    pipe = pipeline("text-to-audio", model="Matthijs/mms-tts-eng")
    audio_data = pipe(text)
    return audio_data

st.set_page_config(page_title="Tweet Toxicity Analysis")

st.header("Please input a Tweet for Toxicity Analysis :performing_arts:")
input = st.text_area("Enter a Tweer for analysis")
result = toxic_model(input)

  # Display the result
st.write("Tweet:", input)
st.write("label:", result[0]['label'])
st.write("score:", result[0]['score'])

audio_data1 = text2audio(input)
st.audio(audio_data1['audio'],
                     format="audio/wav",
                     start_time=0,
                     sample_rate = audio_data['sampling_rate'])

audio_data2 = text2audio(result[0]['label'])
st.audio(audio_data2['audio'],
                     format="audio/wav",
                     start_time=0,
                     sample_rate = audio_data['sampling_rate'])