refactor: refactor podcast genration stability (#11)

This commit is contained in:
DanielWalnut 2025-05-09 11:34:19 +08:00 committed by GitHub
parent 9213729ef5
commit f8b718fcc1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 50 deletions

View File

@ -42,6 +42,7 @@ In this demo, we showcase how to use DeerFlow to:
- [❓ FAQ](#faq) - [❓ FAQ](#faq)
- [📜 License](#license) - [📜 License](#license)
- [💖 Acknowledgments](#acknowledgments) - [💖 Acknowledgments](#acknowledgments)
- [⭐ Star History](#star-history)
## Quick Start ## Quick Start
@ -465,3 +466,7 @@ A heartfelt thank you goes out to the core authors of `DeerFlow`, whose vision,
- **[Henry Li](https://github.com/magiccube/)** - **[Henry Li](https://github.com/magiccube/)**
Your unwavering commitment and expertise have been the driving force behind DeerFlow's success. We are honored to have you at the helm of this journey. Your unwavering commitment and expertise have been the driving force behind DeerFlow's success. We are honored to have you at the helm of this journey.
## ⭐ Star History
[![Star History Chart](https://api.star-history.com/svg?repos=bytedance/deer-flow&type=Date)](https://star-history.com/#bytedance/deer-flow&Date)

View File

@ -16,9 +16,9 @@ def tts_node(state: PodcastState):
tts_client = _create_tts_client() tts_client = _create_tts_client()
for line in state["script"].lines: for line in state["script"].lines:
tts_client.voice_type = ( tts_client.voice_type = (
"BV033_streaming" if line.speaker == "male" else "BV034_streaming" "BV002_streaming" if line.speaker == "male" else "BV001_streaming"
) )
result = tts_client.text_to_speech(line.text, speed_ratio=1.05) result = tts_client.text_to_speech(line.paragraph, speed_ratio=1.05)
if result["success"]: if result["success"]:
audio_data = result["audio_data"] audio_data = result["audio_data"]
audio_chunk = base64.b64decode(audio_data) audio_chunk = base64.b64decode(audio_data)

View File

@ -8,7 +8,7 @@ from pydantic import BaseModel, Field
class ScriptLine(BaseModel): class ScriptLine(BaseModel):
speaker: Literal["male", "female"] = Field(default="male") speaker: Literal["male", "female"] = Field(default="male")
text: str = Field(default="") paragraph: str = Field(default="")
class Script(BaseModel): class Script(BaseModel):

View File

@ -11,12 +11,12 @@ You are a professional podcast editor for a show called "Hello Deer." Transform
# Output Format # Output Format
The output should be formatted as a valid, parseable JSON object of `Script` without "```json": The output should be formatted as a valid, parseable JSON object of `Script` without "```json". The `Script` interface is defined as follows:
```ts ```ts
interface ScriptLine { interface ScriptLine {
speaker: 'male' | 'female'; speaker: 'male' | 'female';
text: string; // only plain text, never Markdown paragraph: string; // only plain text, never Markdown
} }
interface Script { interface Script {
@ -25,51 +25,6 @@ interface Script {
} }
``` ```
# Examples
<example>
{
"locale": "en",
"lines": [
{
"speaker": "male",
"text": "Hey everyone, welcome to the podcast Hello Deer!"
},
{
"speaker": "female",
"text": "Hi there! Today, were diving into something super interesting."
},
{
"speaker": "male",
"text": "Yeah, were talking about [topic]. You know, Ive been thinking about this a lot lately."
},
{
"speaker": "female",
"text": "Oh, me too! Its such a fascinating subject. So, lets start with [specific detail or question]."
},
{
"speaker": "male",
"text": "Sure! Did you know that [fact or insight]? Its kind of mind-blowing, right?"
},
{
"speaker": "female",
"text": "Totally! And it makes me wonder, what about [related question or thought]?"
},
{
"speaker": "male",
"text": "Great point! Actually, [additional detail or answer]."
},
{
"speaker": "female",
"text": "Wow, thats so cool. I didnt know that! Okay, so what about [next topic or transition]?"
},
...
]
}
</example>
> Real examples should be **MUCH MUCH LONGER** and more detailed, with placeholders replaced by actual content.
# Notes # Notes
- It should always start with "Hello Deer" podcast greetings and followed by topic introduction. - It should always start with "Hello Deer" podcast greetings and followed by topic introduction.