Skip to content

Commit 3393590

Browse files
committed
migrating to sherpaonnx from mms
1 parent fda5dd6 commit 3393590

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Note: tts-data/**vendor**-**software**.json is a list of tts engines not support
88

99
To-Do
1010

11-
- Add Ivona, Nuance etc voices
1211
- Add software specific variants like Smartbox
1312
- Add in eSpeak-NG
1413
- Investigate NVDA at some point

main.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from fastapi import FastAPI, Query, HTTPException
22
from typing import List, Optional, Dict, Any, Union
33
from pydantic import BaseModel
4-
from tts_wrapper import PollyTTS, PollyClient, GoogleTTS, GoogleClient, MicrosoftTTS, MicrosoftClient, WatsonTTS, WatsonClient, ElevenLabsTTS, ElevenLabsClient, WitAiTTS, WitAiClient, MMSTTS, MMSClient
4+
from tts_wrapper import PollyTTS, PollyClient, GoogleTTS, GoogleClient, MicrosoftTTS, MicrosoftClient, WatsonTTS, WatsonClient, ElevenLabsTTS, ElevenLabsClient, WitAiTTS, WitAiClient, SherpaOnnxTTS, SherpaOnnxClient
55
import os
66
import json
77
from datetime import datetime, timedelta
@@ -20,7 +20,7 @@
2020
cache = {}
2121

2222
# List of engines for dropdown - we update this im main
23-
engines_list = ["polly", "google", "microsoft", "watson", "elevenlabs", "witai", "mms"]
23+
engines_list = ["polly", "google", "microsoft", "watson", "elevenlabs", "witai", "sherpaonnx"]
2424

2525

2626
def load_tts_engines(directory):
@@ -137,9 +137,9 @@ def get_client(engine: str):
137137
token = os.getenv('WITAI_TOKEN')
138138
logger.info(f"WitAi Token: {token}")
139139
return WitAiClient(credentials=(token))
140-
elif engine == 'mms':
141-
logger.info("Creating MMS client")
142-
return MMSClient()
140+
elif engine == 'sherpaonnx':
141+
logger.info("Creating SherpaOnnx client")
142+
return SherpaOnnxClient()
143143
else:
144144
logger.error(f"Invalid engine: {engine}")
145145
return None
@@ -158,8 +158,8 @@ def get_tts(engine: str):
158158
return ElevenLabsTTS(client)
159159
elif engine == 'witai':
160160
return WitAiTTS(client)
161-
elif engine == 'mms':
162-
return MMSTTS(client)
161+
elif engine == 'sherpaonnx':
162+
return SherpaOnnxTTS(client)
163163
else:
164164
return None
165165

@@ -194,6 +194,7 @@ def get_cached_voices(engine: str):
194194
def get_voices(engine: Optional[str] = Query(None, enum=engines_list), lang_code: Optional[str] = None, lang_name: Optional[str] = None, name: Optional[str] = None, gender: Optional[str] = None, page: Optional[int] = 1, page_size: Optional[int] = 50, ignore_cache: Optional[bool] = False):
195195
voices = []
196196
if engine:
197+
print(f"Fetching voices for engine as engine exists: {engine}")
197198
if not ignore_cache:
198199
voices = get_cached_voices(engine.lower())
199200
if not voices:
@@ -202,8 +203,11 @@ def get_voices(engine: Optional[str] = Query(None, enum=engines_list), lang_code
202203
cache_voices(engine.lower(), voices)
203204
else:
204205
for eng in engines_list:
206+
print(f"Fetching voices for engine: {eng}")
205207
if not ignore_cache:
206208
eng_voices = get_cached_voices(eng)
209+
if eng == 'SherpaOnnx':
210+
print(f"Eng voices: {eng_voices}")
207211
if not eng_voices:
208212
try:
209213
eng_voices = load_voices_from_source(eng)

requirements.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
fastapi==0.85.1
22
uvicorn[standard]==0.19.0
33
pydantic==1.10.2
4-
git+https://github.com/willwade/py3-tts#egg=py3-tts
5-
git+https://github.com/willwade/tts-wrapper#egg=tts-wrapper[google,watson,microsoft,polly,elevenlabs,mms]
4+
git+https://github.com/willwade/tts-wrapper#egg=tts-wrapper[google,watson,microsoft,polly,elevenlabs,sherpaonnx]
65
fuzzysearch

0 commit comments

Comments
 (0)