From 4361f17148fe2854e55b499c15a74e1f64e6ebde Mon Sep 17 00:00:00 2001 From: danil Date: Thu, 11 Jul 2024 17:03:40 +0500 Subject: [PATCH] fix voice --- supabase/functions/_shared/supabase/ai.ts | 5 +++-- supabase/functions/ai-koshey/index.ts | 3 ++- supabase/functions/synclabs-audio/index.ts | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/supabase/functions/_shared/supabase/ai.ts b/supabase/functions/_shared/supabase/ai.ts index 533c41b..af5ad03 100644 --- a/supabase/functions/_shared/supabase/ai.ts +++ b/supabase/functions/_shared/supabase/ai.ts @@ -257,12 +257,13 @@ export async function createVoiceSyncLabs( } } -export async function isVoiceId(voiceId: string) { +export async function isVoiceId(telegram_id: string) { const { data, error } = await supabase .from("users") .select("*") - .eq("voice_id_synclabs", voiceId) + .eq("telegram_id", telegram_id) .single(); + if (error || !data) return false; return true; } diff --git a/supabase/functions/ai-koshey/index.ts b/supabase/functions/ai-koshey/index.ts index 43a818f..98cf5c1 100644 --- a/supabase/functions/ai-koshey/index.ts +++ b/supabase/functions/ai-koshey/index.ts @@ -1036,8 +1036,9 @@ botAiKoshey.command("text_to_speech", async (ctx) => { const lang = await isRu(ctx) if (!ctx.from?.id) throw new Error("No user id"); const isHaveVoiceId = await isVoiceId(ctx.from?.id.toString()) + console.log(isHaveVoiceId, "isHaveVoiceId") if (!isHaveVoiceId) { - await ctx.reply(lang ? "🔮 Пожалуйста, перед использованием /text_to_speech используйте /voice." : "🔮 Please use /voice before using /text_to_speech.") + await ctx.reply(lang ? "🔮 Пожалуйста, для использованием /text_to_speech, введите /voice." : "🔮 Please enter /voice to use /text_to_speech.") return } const text = lang diff --git a/supabase/functions/synclabs-audio/index.ts b/supabase/functions/synclabs-audio/index.ts index f096b64..7350842 100644 --- a/supabase/functions/synclabs-audio/index.ts +++ b/supabase/functions/synclabs-audio/index.ts @@ -29,8 +29,8 @@ Deno.serve(async (req) => { console.log(voice_id, "voice_id"); const user = await getUserByVoiceId(voice_id); console.log(user, "user"); - //const chat_id = user?.chat_id; - const chat_id = "1006101665" + const chat_id = user?.chat_id; + // const chat_id = "1006101665" console.log(chat_id, "chat_id"); try { await botAiKoshey.api.sendVoice(chat_id, audioUrl); @@ -65,4 +65,4 @@ Deno.serve(async (req) => { */ -// supabase functions deploy heygen-video --no-verify-jwt \ No newline at end of file +// supabase functions deploy synclabs-audio --no-verify-jwt \ No newline at end of file