File size: 826 Bytes
321fb0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import torch
import torchaudio
from transformers import pipeline
import streamlit as st

x = st.slider('Select a value')
st.write(x, 'squared is', x * x)


model_id = '11mlabs/indri-0.1-124m-tts'
task = 'indri-tts'

pipe = pipeline(
    task,
    model=model_id,
    #device=torch.device('cuda:0'), # Update this based on your hardware,
    trust_remote_code=True
)

text_input = st.text_area("Enter text for TTS (max 200 characters):", max_chars=200)

speaker_name = st.text_input("Enter speaker's name:")

if st.button("Generate Audio"):
    if text_input:
        output = pipe([text_input], speaker=speaker_name)
        torchaudio.save('output.wav', output[0]['audio'][0], sample_rate=24000)
        st.audio('output.wav')  # Display audio blob output
    else:
        st.warning("Please enter text to generate audio.")