Fanny1366 commited on
Commit
85a0c1a
·
verified ·
1 Parent(s): bcc6534

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -3,6 +3,7 @@ import streamlit as st
3
  from transformers import pipeline
4
  import soundfile as sf
5
  import numpy as np
 
6
 
7
  # function part
8
  # img2text
@@ -13,7 +14,7 @@ def img2text(url):
13
 
14
  # text2story
15
  def text2story(text):
16
- story_text_model = pipeline("text-generation", model="meta-llama/Llama-3.1-8B")
17
  story = story_text_model(text, max_length=150)[0]['generated_text']
18
  return story
19
 
@@ -22,8 +23,8 @@ def text2audio(story_text):
22
  tts_model = pipeline("text-to-speech", model="tts_models/en/ljspeech/tacotron2")
23
  audio_data = tts_model(story_text)
24
 
25
- # Save audio to a file
26
- audio_filename = "story_audio.wav"
27
  sf.write(audio_filename, audio_data['audio'], audio_data['sampling_rate'])
28
 
29
  return audio_filename
 
3
  from transformers import pipeline
4
  import soundfile as sf
5
  import numpy as np
6
+ import tempfile
7
 
8
  # function part
9
  # img2text
 
14
 
15
  # text2story
16
  def text2story(text):
17
+ story_text_model = pipeline("text-generation", model="google/gemma-2-9b-it")
18
  story = story_text_model(text, max_length=150)[0]['generated_text']
19
  return story
20
 
 
23
  tts_model = pipeline("text-to-speech", model="tts_models/en/ljspeech/tacotron2")
24
  audio_data = tts_model(story_text)
25
 
26
+ # Save audio to a temporary file
27
+ audio_filename = tempfile.mktemp(suffix=".wav")
28
  sf.write(audio_filename, audio_data['audio'], audio_data['sampling_rate'])
29
 
30
  return audio_filename