enable gemini text to speech model for podcast generation

This commit is contained in:
LUIS NOVO 2024-11-07 19:45:56 -03:00
parent ab4cd8f5f9
commit 7978833473
9 changed files with 561 additions and 516 deletions

View file

@ -87,10 +87,7 @@ Learn more about our project at [https://www.open-notebook.ai](https://www.open-
### Built With
* [![Python][Python]][Python-url]
* [![SurrealDB][SurrealDB]][SurrealDB-url]
* [![LangChain][LangChain]][LangChain-url]
* [![Streamlit][Streamlit]][Streamlit-url]
[![Python][Python]][Python-url] [![SurrealDB][SurrealDB]][SurrealDB-url] [![LangChain][LangChain]][LangChain-url] [![Streamlit][Streamlit]][Streamlit-url]
<p align="right">(<a href="#readme-top">back to top</a>)</p>
@ -156,6 +153,10 @@ Go to the [Usage](docs/USAGE.md) page to learn how to use all features.
## 🚀 New Features
### v0.0.9 - Ask your Documents and Citations ❓
- Ask questions about your documents and get answers with citations
### v0.0.7 - Model Management 🗂️
- Manage your AI models and providers in a single interface

View file

@ -14,10 +14,17 @@ Setup a template for your podcast, you can get very creative here.
- Pick a language for the podcast
- Customize conversation style, engagement techniques, dialogue structure
- Define the length of each episode
- Pick your voice models (Open AI and Eleven Labs supported)
- Pick your voice models (Open AI, Gemini and Eleven Labs supported)
![Podcast Temmplates](assets/podcast_template.png)
### ⚠️ Important instructions for Gemini
The new Gemini Text to Speech models are amazing and definitely worth using. But in order to use them, you need to do a little setup. Please refer to this [Podcastfy help page](https://github.com/souzatharsis/podcastfy/blob/main/usage/config.md) for details. But it basically requires you to enable the Text to Speech API and add it to your API Key.
### Pick your context
Pick the specific context you'd like to use to base your podcast.

View file

@ -24,6 +24,7 @@ from open_notebook.models.speech_to_text_models import (
)
from open_notebook.models.text_to_speech_models import (
ElevenLabsTextToSpeechModel,
GeminiTextToSpeechModel,
OpenAITextToSpeechModel,
TextToSpeechModel,
)
@ -56,6 +57,7 @@ MODEL_CLASS_MAP: Dict[str, ProviderMap] = {
"text_to_speech": {
"openai": OpenAITextToSpeechModel,
"elevenlabs": ElevenLabsTextToSpeechModel,
"gemini": GeminiTextToSpeechModel,
},
}

View file

@ -24,3 +24,8 @@ class OpenAITextToSpeechModel(TextToSpeechModel):
@dataclass
class ElevenLabsTextToSpeechModel(TextToSpeechModel):
model_name: str
@dataclass
class GeminiTextToSpeechModel(TextToSpeechModel):
model_name: str

View file

@ -97,6 +97,10 @@ with templates_tab:
st.markdown(
"[Open AI voices](https://platform.openai.com/docs/guides/text-to-speech)"
)
st.markdown(
"[Gemini voices](https://cloud.google.com/text-to-speech/docs/voices)"
)
pd_cfg["voice2"] = st.text_input(
"Voice 2", help="You can use Elevenlabs voice ID"
)
@ -211,6 +215,9 @@ with templates_tab:
st.markdown(
"[Open AI voices](https://platform.openai.com/docs/guides/text-to-speech)"
)
st.markdown(
"[Gemini voices](https://cloud.google.com/text-to-speech/docs/voices)"
)
pd_config.voice2 = st.text_input(
"Voice 2",
value=pd_config.voice2,

View file

@ -77,9 +77,13 @@ with model_tab:
available_model_types,
help="Use language for text generation models, text_to_speech for TTS models for generating podcasts, etc.",
)
model_name = st.text_input(
"Model Name", "", help="gpt-4o-mini, claude, gemini, llama3, etc"
)
if model_type == "text_to_speech" and provider == "gemini":
model_name = "gemini-default"
st.markdown("Gemini models are pre-configured. Using the default model.")
else:
model_name = st.text_input(
"Model Name", "", help="gpt-4o-mini, claude, gemini, llama3, etc"
)
if st.button("Save"):
model = Model(name=model_name, provider=provider, type=model_type)
model.save()

View file

@ -88,14 +88,17 @@ def chat_sidebar(current_notebook: Notebook, current_session: ChatSession):
"No notes or sources found in context. You don't want a boring podcast, right? So, add some context first."
)
else:
if st.button("Generate"):
with st.spinner("Go grab a coffee, almost there..."):
selected_template.generate_episode(
episode_name=episode_name,
text=context,
instructions=instructions,
)
st.success("Episode generated successfully")
try:
if st.button("Generate"):
with st.spinner("Go grab a coffee, almost there..."):
selected_template.generate_episode(
episode_name=episode_name,
text=context,
instructions=instructions,
)
st.success("Episode generated successfully")
except Exception as e:
st.error(f"Error generating episode - {str(e)}")
st.page_link("pages/5_🎙_Podcasts.py", label="🎙️ Go to Podcasts")
with chat_tab:
with st.expander(

1012
poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "open-notebook"
version = "0.0.9"
version = "0.0.10"
description = "An open source implementation of a research assistant, inspired by Google Notebook LM"
authors = ["Luis Novo <lfnovo@gmail.com>"]
license = "MIT"
@ -40,7 +40,7 @@ langchain-ollama = "^0.2.0"
langchain-google-vertexai = "^2.0.5"
sdblpy = "^0.3.0"
langchain-google-genai = "^2.0.1"
podcastfy = "^0.2.8"
podcastfy = "^0.3.2"
tomli = "^2.0.2"
bs4 = "^0.0.2"
python-docx = "^1.1.2"