First Push

This commit is contained in:
2025-12-09 11:17:24 +00:00
parent 5c7b339bdf
commit 1c495079eb
8 changed files with 154 additions and 2 deletions

View File

@@ -316,7 +316,7 @@
- Test error handling for unavailable service
- _Requirements: 14.1, 14.2, 14.3_
- [ ] 16. Integrate Ollama into role detection
- [x] 16. Integrate Ollama into role detection
- Update RoleDetector to use OllamaService
- Implement _detect_with_ollama() method
- Add fallback logic: try Ollama first, then pattern matching

63
Test Story.txt Normal file
View File

@@ -0,0 +1,63 @@
Once upon a time, in a tiny village surrounded by lush green forests, there lived three best friends: Lily the rabbit, Benny the bear, and Sammy the squirrel. They loved to explore the woods together, playing hide-and-seek behind trees and chasing after butterflies.
One sunny afternoon, they decided to have a picnic on a hill overlooking the forest. They brought their favorite snacks – carrots for Lily, honey sandwiches for Benny, and acorn cookies for Sammy.
As they sat down on a blanket, Lily asked, "Have you guys heard about the new stream that just appeared in the woods?"
Benny's eyes lit up. "Ooh, I love streams! Do we get to go see it now?"
Sammy nodded enthusiastically. "I've been wanting to explore the forest more since the snow melted. Let's go!"
Lily grinned. "But first, let's finish our snacks and enjoy the view. We can go see the stream after that."
As they munched on their treats, Benny started telling a joke: "Why did the bear go to the party?"
Sammy chuckled. "I don't know, why?"
Benny laughed. "Because he was grizzly good at dancing!"
Lily giggled. "Oh, Benny, you're such a pun master!"
After finishing their snacks, they packed up the remains and set off towards the stream. As they walked, Sammy pointed out different types of leaves and flowers growing along the path.
Benny asked, "Sammy, how do you know so much about plants?"
Sammy beamed with pride. "My mom is a great botanist. She taught me all about the different species in our forest."
Lily nodded. "I've seen her collecting samples and making notes before. She's very smart!"
As they approached the stream, Benny exclaimed, "Wow! Look at that! It's so clear and sparkly!"
Sammy gasped. "And look, there are fish swimming in it!"
Lily clapped her paws together. "This is going to be so much fun! Let's catch some fish for lunch!"
Benny and Sammy cheered as they started skipping stones across the stream. Lily laughed as she tried to catch the fish with a makeshift net made from vines.
As they played, Benny noticed something strange. "Guys, look up there."
Sammy followed his gaze and gasped. A small waterfall cascaded down a rocky cliff, creating a misty veil that surrounded them.
Lily's eyes widened. "This is amazing! I've never seen anything like it!"
Benny grinned. "I think we should name this place the 'Misty Grotto'!"
Sammy nodded enthusiastically. "And we can come back and explore more tomorrow!"
As the sun began to set, they reluctantly said their goodbyes to the stream and headed back to the village. As they walked, Lily asked, "Benny, what's your favorite thing about our forest?"
Benny thought for a moment before responding, "I think it's all the hidden treasures we find along the way. Like this stream or that waterfall."
Sammy nodded in agreement. "And there are always new things to discover! That's what I love most about our forest too."
Lily smiled. "For me, it's the friends I make and the adventures we have together. You guys are my favorite treasures!"
As they approached the village, Benny turned to his friends and said, "You know what? Let's plan a camping trip for next weekend! We can bring sleeping bags and roast marshmallows over a campfire!"
Sammy's eyes lit up. "That sounds like so much fun! Can we invite some other villagers too?"
Lily nodded. "I'm sure Mom would love to come. She's always telling me about the camping trips she went on when she was younger."
Benny grinned. "It'll be a blast! Let's get planning and make it the best camping trip ever!"
As they entered their cozy little homes, Lily, Benny, and Sammy all smiled, knowing that they had each other and the magical forest to explore, filled with hidden treasures and endless adventures waiting to be discovered.

10
backend/check_voices.py Normal file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env python3
"""Check available Kokoro TTS voices."""
from kokoro import VOICE_NAMES
print("Available Kokoro TTS voices:")
print("=" * 50)
for voice in sorted(VOICE_NAMES):
print(f" {voice}")
print("=" * 50)
print(f"Total: {len(VOICE_NAMES)} voices")

View File

@@ -29,3 +29,27 @@ INFO: 127.0.0.1:53090 - "POST /api/tts HTTP/1.1" 400 Bad Request
2025-12-09 01:20:19,494 - services.tts_service - INFO - Generated audiobook: 44 bytes
WARNING: Defaulting repo_id to hexgrad/Kokoro-82M. Pass repo_id='hexgrad/Kokoro-82M' to suppress this warning.
INFO: 127.0.0.1:53092 - "POST /api/tts HTTP/1.1" 200 OK
INFO: 127.0.0.1:54291 - "OPTIONS /api/tts/roles HTTP/1.1" 200 OK
2025-12-09 10:15:45,219 - main - INFO - Role detection requested for text of length 4
2025-12-09 10:15:45,226 - main - INFO - Detected 1 roles: ['Narrator']
INFO: 127.0.0.1:54291 - "POST /api/tts/roles HTTP/1.1" 200 OK
INFO: 127.0.0.1:54296 - "OPTIONS /api/tts HTTP/1.1" 200 OK
2025-12-09 10:15:51,949 - main - INFO - Audio generation requested: lang=a, roles=1, speed=1.0
2025-12-09 10:15:51,953 - services.tts_service - INFO - Generating audiobook: lang=a, speed=1.0, roles=1
2025-12-09 10:15:51,955 - services.tts_service - INFO - Segmented text into 1 segments
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Python runtime state: core initialized
OSError: [Errno 9] Bad file descriptor
Current thread 0x00000001f799e080 (most recent call first):
<no Python frame>
2025-12-09 10:15:55,293 - services.tts_service - INFO - Generated audiobook: 44 bytes
INFO: 127.0.0.1:54296 - "POST /api/tts HTTP/1.1" 200 OK
2025-12-09 10:16:52,356 - main - INFO - Role detection requested for text of length 40
2025-12-09 10:16:52,358 - main - INFO - Detected 1 roles: ['Narrator']
INFO: 127.0.0.1:54431 - "POST /api/tts/roles HTTP/1.1" 200 OK
2025-12-09 10:17:02,016 - main - INFO - Audio generation requested: lang=a, roles=1, speed=1.0
2025-12-09 10:17:02,017 - services.tts_service - INFO - Generating audiobook: lang=a, speed=1.0, roles=1
2025-12-09 10:17:02,018 - services.tts_service - INFO - Segmented text into 1 segments
2025-12-09 10:17:02,814 - services.tts_service - INFO - Generated audiobook: 44 bytes
INFO: 127.0.0.1:54433 - "POST /api/tts HTTP/1.1" 200 OK

4
backend/start_backend.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
cd "$(dirname "$0")"
source venv/bin/activate
uvicorn main:app --reload --host 0.0.0.0 --port 8002

View File

@@ -1 +1 @@
VITE_API_BASE_URL=http://localhost:8000
VITE_API_BASE_URL=http://localhost:8002

27
test_my_story.py Normal file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env python3
import sys
sys.path.insert(0, 'backend')
import asyncio
from services.role_detector import RoleDetector
from services.ollama_service import OllamaService
async def test():
# Read the actual story
with open('Test Story.txt', 'r') as f:
story = f.read()
print(f'Story length: {len(story)} characters\n')
# Test role detection
ollama_service = OllamaService()
role_detector = RoleDetector(ollama_service=ollama_service)
print('Testing role detection...')
roles = await role_detector.detect_roles(story)
print(f'\nDetected {len(roles)} roles:')
for role in roles:
print(f' - {role["label"]}')
asyncio.run(test())

24
test_ollama_quick.py Normal file
View File

@@ -0,0 +1,24 @@
#!/usr/bin/env python3
import sys
sys.path.insert(0, 'backend')
import asyncio
from services.ollama_service import OllamaService
async def test():
service = OllamaService()
available = await service.is_available()
print(f'Ollama available: {available}')
if available:
text = '''Lily asked, "Have you guys heard about the new stream?"
Benny's eyes lit up. "Ooh, I love streams!"
Sammy nodded enthusiastically. "I've been wanting to explore!"'''
print(f'\nTesting with sample text ({len(text)} chars)...')
speakers = await service.detect_speakers(text)
print(f'Detected speakers: {speakers}')
else:
print('Ollama is not available!')
asyncio.run(test())