Hi,
In compiling my project, an imported nim source code file (ReTTS.nim) throws an error. However when I compile it seperately, it compiles just fine... The same file compiled also fine when imported in a limited test project setup (only for testing out the working with some basic code in ReTest.nim which imported ReTTS).
When compiled as import (nim c -r --threads:on ReMain.nim) this is the error on line 54 (var voicenames: seq[string] in proc getVoiceNames) near the bottom of the snippet :
ReMain.nim(2325, 36) template/generic instantiation of `getVoiceNames` from here
``Re_tts.nim(54, 24) Error: no generic parameters allowed for seq``
But when compiled separately (nim c -r --threads:on ReTTS.nim) all goes well :
CC: stdlib_logging.nim
CC: RE_log.nim
CC: Re_tts.nim
Hint: [Link]
Hint: 1287218 lines; 17.373s; 434.992MiB peakmem; Debug build; proj: ReTTS; out: C:\Users\Ivan\GFR\Re_tts.exe [SuccessX]
Hint: C:\Users\Ivan\GFR\ReTTS.exe [Exec]
import os
import winim/com
import sequtils
import strutils
import strformat
import ReData
import RePlaywav
import ReLog
var
ttsSPK: com
ttsWAV: com
ttsVoices: variant
proc ttsInit*(): bool =
try:
ttsSPK = CreateObject("SAPI.SpVoice")
ttsWAV = CreateObject("SAPI.SpVoice")
ttsVoices = ttsSPK.GetVoices() # only one Sapi engine, so will be the same for SPK and WAV
return true
except:
log("Could not initialize speech engine")
return false
proc ttsExit*(): bool =
try:
COM_FullRelease()
return true
except:
log("Could not free speech engine")
return false
proc setPitchSSML(utterance: string, pitch: int = 0): string =
var utter: string = utterance
if pitch != 0:
utter = fmt("<pitch middle='{pitch:+d}'>") & utterance & "</pitch>"
return utter
proc setVoiceByName(voicename: string) =
# if this fails, it is neglected it will default to standard or last voice
var voicedescription: string
# echo "----DEBUG -- Trying to set voice by name: ", voicename
let cnt = ttsVoices.count()
for idx in 0 ..< cnt:
voicedescription = ttsVoices.item(idx).getDescription()
if voicedescription.contains(voicename):
ttsVoices.item(idx).getDescription()
# set for both outputs : speaker and wav file
ttsSPK.setRef("Voice", ttsVoices.item(idx))
ttsWAV.setRef("Voice", ttsVoices.item(idx))
proc getVoiceNames*(): seq =
var voicenames: seq[string]
ttsVoices = ttsSPK.GetVoices()
let cnt = ttsVoices.count()
for idx in 0 ..< cnt:
#echo ttsVoices.item(idx).id
voicenames.add(ttsVoices.item(idx).getDescription())
return voicenames
the code in ReMain.nim that does the call is :
voiceList = getVoiceNames()
and voiceList is declared in the beginning of the ReMain source file as *** var voiceList: seq[string] = @[] ***
Is this a bug, since it compiled fine in the test project, but not in my complete project ?
More important: how to solve this ?
proc getVoiceNames*(): seq =
You need to specify the seq of what: proc getVoiceNames*(): seq[string] =
Thank you.
My bad. I must have deleted part of the code by mistake, because in a previous version of the file it does say proc getVoiceNames¨(): seq[string] =