Merge pull request #17 from lfnovo/podcast2

Enable gemini text to speech model for podcast generation
This commit is contained in:
Luis Novo 2024-11-07 19:46:56 -03:00 committed by GitHub
commit 7e96fdad5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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 ### Built With
* [![Python][Python]][Python-url] [![Python][Python]][Python-url] [![SurrealDB][SurrealDB]][SurrealDB-url] [![LangChain][LangChain]][LangChain-url] [![Streamlit][Streamlit]][Streamlit-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> <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 ## 🚀 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 🗂️ ### v0.0.7 - Model Management 🗂️
- Manage your AI models and providers in a single interface - 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 - Pick a language for the podcast
- Customize conversation style, engagement techniques, dialogue structure - Customize conversation style, engagement techniques, dialogue structure
- Define the length of each episode - 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) ![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 your context
Pick the specific context you'd like to use to base your podcast. 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 ( from open_notebook.models.text_to_speech_models import (
ElevenLabsTextToSpeechModel, ElevenLabsTextToSpeechModel,
GeminiTextToSpeechModel,
OpenAITextToSpeechModel, OpenAITextToSpeechModel,
TextToSpeechModel, TextToSpeechModel,
) )
@ -56,6 +57,7 @@ MODEL_CLASS_MAP: Dict[str, ProviderMap] = {
"text_to_speech": { "text_to_speech": {
"openai": OpenAITextToSpeechModel, "openai": OpenAITextToSpeechModel,
"elevenlabs": ElevenLabsTextToSpeechModel, "elevenlabs": ElevenLabsTextToSpeechModel,
"gemini": GeminiTextToSpeechModel,
}, },
} }

View file

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

View file

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

View file

@ -77,9 +77,13 @@ with model_tab:
available_model_types, available_model_types,
help="Use language for text generation models, text_to_speech for TTS models for generating podcasts, etc.", help="Use language for text generation models, text_to_speech for TTS models for generating podcasts, etc.",
) )
model_name = st.text_input( if model_type == "text_to_speech" and provider == "gemini":
"Model Name", "", help="gpt-4o-mini, claude, gemini, llama3, etc" 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"): if st.button("Save"):
model = Model(name=model_name, provider=provider, type=model_type) model = Model(name=model_name, provider=provider, type=model_type)
model.save() 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." "No notes or sources found in context. You don't want a boring podcast, right? So, add some context first."
) )
else: else:
if st.button("Generate"): try:
with st.spinner("Go grab a coffee, almost there..."): if st.button("Generate"):
selected_template.generate_episode( with st.spinner("Go grab a coffee, almost there..."):
episode_name=episode_name, selected_template.generate_episode(
text=context, episode_name=episode_name,
instructions=instructions, text=context,
) instructions=instructions,
st.success("Episode generated successfully") )
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") st.page_link("pages/5_🎙_Podcasts.py", label="🎙️ Go to Podcasts")
with chat_tab: with chat_tab:
with st.expander( 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] [tool.poetry]
name = "open-notebook" 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" description = "An open source implementation of a research assistant, inspired by Google Notebook LM"
authors = ["Luis Novo <lfnovo@gmail.com>"] authors = ["Luis Novo <lfnovo@gmail.com>"]
license = "MIT" license = "MIT"
@ -40,7 +40,7 @@ langchain-ollama = "^0.2.0"
langchain-google-vertexai = "^2.0.5" langchain-google-vertexai = "^2.0.5"
sdblpy = "^0.3.0" sdblpy = "^0.3.0"
langchain-google-genai = "^2.0.1" langchain-google-genai = "^2.0.1"
podcastfy = "^0.2.8" podcastfy = "^0.3.2"
tomli = "^2.0.2" tomli = "^2.0.2"
bs4 = "^0.0.2" bs4 = "^0.0.2"
python-docx = "^1.1.2" python-docx = "^1.1.2"