Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Lobehub TTS service for custom endpoint like ollama #107

Merged
merged 16 commits into from
Feb 9, 2025

Conversation

moojing
Copy link
Contributor

@moojing moojing commented Feb 1, 2025

Summary

When use Chatgpt's model with openai client, you don't need further settings for TTS service, but we have to add custom TTS service for ollama. (However, we can use openai client with ollama directly.)

To test this feature, you need to set the config as below:

[global]
ankiHost = "http://localhost:8765"
openaiApiKey = "ollama"  
modelProvider = "ollama"
#...

The ttsVoice is changed to set within each responseField.
And decks.responseFields also need to be set as

explanation_en.description = "Detailed explanation in English"
explanation_en.required = true
explanation_en.audio = true
explanation_en.locale = "en-US"
explanation_en.ttsVoice = "en-US-GuyNeural"

You can see all of the available voices here

Screenshot

Screen.Recording.2025-02-02.at.6.54.57.PM.mov

@@ -72,6 +72,7 @@ export async function learn(options: LearnOptions = {}) {
ankiService,
openaiService,
options.debug,
config.global.ttsVoice,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to update other ContentManager usage

@Yukaii Yukaii linked an issue Feb 1, 2025 that may be closed by this pull request
src/services/openai.ts Show resolved Hide resolved
src/services/openai.ts Outdated Show resolved Hide resolved
src/services/openai.ts Show resolved Hide resolved
@moojing moojing marked this pull request as ready for review February 2, 2025 18:52
@@ -28,7 +28,7 @@ export async function serve(options: ServeOptions = {}) {
config.global.openai.ttsModel,
debug,
);
const contentManager = new ContentManager(ankiService, openaiService, debug);
const contentManager = new ContentManager(ankiService, openaiService,debug);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use bun run fmt to ensure code formatting consistency

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/services/openai.ts Outdated Show resolved Hide resolved
src/services/openai.ts Outdated Show resolved Hide resolved
src/services/openai.ts Outdated Show resolved Hide resolved
src/services/content-manager.ts Outdated Show resolved Hide resolved
@moojing moojing force-pushed the feat/ollama-endpoint branch from 5527e22 to 6df39fb Compare February 3, 2025 20:26
@moojing
Copy link
Contributor Author

moojing commented Feb 3, 2025

BTW, I found that we just need bun run --hot src/index.ts serve to get hot reload feature for server development. I've add it into package.json's script

Copy link
Owner

@Yukaii Yukaii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your awesome contribution! It is hugely appreciated.

@Yukaii Yukaii merged commit dc53c70 into Yukaii:main Feb 9, 2025
3 checks passed
@moojing
Copy link
Contributor Author

moojing commented Feb 9, 2025

Thanks for your awesome contribution! It is hugely appreciated.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

TTS should be standalone service
2 participants