|
import os |
|
import openai |
|
import gradio as gr |
|
from gtts import gTTS |
|
from transformers import pipeline |
|
from openai import OpenAI |
|
client = OpenAI() |
|
|
|
openai.api_key = os.getenv("OPENAI_API_KEY") |
|
|
|
pipe = pipeline(model="Ussen/whisper-medium-swc-drc-kat-1") |
|
|
|
def transcribe(audio): |
|
text = pipe(audio)["text"] |
|
return text |
|
|
|
def generate_response(transcribed_text): |
|
response = client.chat.completions.create( |
|
|
|
messages=[ |
|
{ |
|
"role": "system", |
|
"content": "All your answers should be in Congolese Swahili only, understand Swahili and France so here we start. Before you answer read the context in this chart find the best answer create a good summary and provide the answer maintaining Congolese Swahili...Mimi ni Haki des femmes AI bot iliyoundwa na Core23Lab. Mimi ni msaidizi wa sauti ya haki ya kumiliki ardhi kwa wanawake nchini DRC. Nikusaidie vipi!" |
|
}, |
|
{ |
|
"role": "user", |
|
"content": "Mambo vipi?" |
|
}, |
|
{ |
|
"role": "assistant", |
|
"content": "Mimi ni Haki des femmes AI bot iliyoundwa na Core23Lab. Mimi ni msaidizi wa sauti ya haki ya kumiliki ardhi kwa wanawake nchini DRC. Nikusaidie vipi" |
|
}, |
|
{ |
|
"role": "user", |
|
"content": "haki za ardhi za wanawake Congo?" |
|
}, |
|
{ |
|
"role": "assistant", |
|
"content": """Sheria au loi ile inangaria bulongo mu jamuri ya kidemokrasia ya kongo ni sheria namba 73-021 ya le 20/07/1973, ile iribadirishwa na |
|
ku ongezwa na sheria namba 80-008 ya le 18/07/1980, ile ina semezea pa régime foncier et immobilier na régime des suretés. |
|
Iyi sheria ayangarie paka regime juridique ya kutumikia bulongo, lakini inanaria pia « regime general des biens », |
|
kwanzia ku article 1 nakufikia ku article 52 na « regime des suretes » kwanzia ku article 245 nakufikia ku article 396. |
|
Lakini tangu 2012, na kuzariwa kwa sheria ya Ohada mu jamuri ya kidemokrasia ya kongo, kipande kia sheria ya bulongo kile |
|
kinangaria regime des sûretés kinakombozwa na acte unisaforme ya Ohada ile inasemea regime des sûretés. |
|
193 articles bule ya mu loi foncière inasemea regime foncier et immobilier (kwanzia ku article 53 nafikia ku article 244) ; |
|
njo ile ma articles ile inawekwa mu disposition ya bale banatumikiaka bulongo (population), bakubwa ba inchi bale banagariaka |
|
mambo ya bulongo (autorités foncières et cadastrales) na ba batshunga sheria (ba avocats na ba magistrats). """ |
|
}, |
|
{ |
|
"role": "user", |
|
"content": "Sheria za Ardhi nchini Congo" |
|
}, |
|
{ |
|
"role": "assistant", |
|
"content": """Sheria aiandike kukatazwa ata kumoya kufwatana na sexe ao bingine nju ya haki yaku tumikia domaine foncier. Lakini, banamuke kiloko njo beko napata ma mpango nju ya kukosa kujua ma procedures, |
|
certificat ya enregistrement, kukosa kwa makuta, incapacité juridique ya mwanamuke mwenye kuolewa, obligation ya autorisation ya bwana yake. |
|
Sheria nᴼ11/022 ya 24/12/2011 ile ina semea ma principes ya musingi ile inangaria agriculture, ina semea accès équitable ya bulongo ile banamuke bakumigini banekalaka ba victimes sana. |
|
Ku migini (milieux ruraux), kupata kwa ma mpango kuna fwatana ma kizazi na chefu wa clan. Lakini, kutumikiya kwa loi nᴼ73 ya le 20/07/1973 vile ili badishwa ina semea regime general, |
|
regime foncier, regime ya suretes, ina semea pa swali ya ma bulongo ya ku rimiapo na kuvukiapo yaku migini. |
|
Mwanamuke mwenye kuolewa eko na haki ya ku piana ma npango ile ilikiya ya bwana yake kama bwana anakufa. |
|
Ata kama bantu abadjue mana, kuolewa kuna tshionganisha kupata kwama mpango njo effet ya kuya mwenye kuolewa kuna saidia kupata mpango nakuyi tumikia. Badjane beko na avantage kupita bale bayaolewa. |
|
Kwa ukweli, nju ya kukosa kufunda banamuke bakumigini abadjue ma procedure yakupata ma pango na aba djue mufano yaku revendiquer na ku tshunga ma haki yabo. |
|
Regime ya ndoa ni kunji ya ma sheria ile iko na weka ma haki na mapashwa ya ba bibi na bwana tangu mwanzo ya ndoa yabo. |
|
Ma regime tatu ya ndoa mu jamuri ya kidemokrasia ya Kongo ni : |
|
1. Regime ya ku kabulamana bintu : mu ile regime, akuna kintu kile kinawekwa pamoja. Kila mwana ndoa eko mwenye kintu kiake kile aripata kabla ndoa, |
|
na wakati banakuya mu ndoa. |
|
Faida : |
|
• Iyi regime iko na kabula muzuri bintu bia wanandoa nju yakusaidia kuriti bintu mu djamaa kutoka kubazazi. |
|
|
|
• Iyi inashauriwa wakati bintu bia wanandoa ao ma jamaa iko ya mana. |
|
|
|
• Ba créanciers ya ba bibi ao bwana abawezi kubeba bintu bia mwingine shisipo ye moya kwitshikia kuripa ndeni ya mwingine ; |
|
njo maana ba entrepreneurs ao bama kaji ya risques ba tshakulaka ile regime. |
|
Bubaya : |
|
• Kutshakula regime kama iyi aina garantie ya ulinzi kumbele ya ba creanciers (bale beko na dayi ndeni) nju banezi ku nyanganya bintu bia ba conjoints kama ndeni |
|
iribewa nju yakutengeneza nyumba ao kuripa masomo ya batoto (ni pamoya nama impôts ao ma charges sociales yasipokulipwa). |
|
|
|
• Ma akounti (comptes) ile barifungula nakuweka pamoya makutamu mu ndoa inezi kuleta shida wakati wakwatshana na ita lomba kuonesha kule kuritoya ile makuta. |
|
|
|
• Wakati wa kifo, ule anabakiya anapashwatu ku tegemea paka pabintu biake nju ya ku garantir maisha yake ya kumbele nju kama akuna testament, ata patatu paka ¼ ya biote bile barikuya bia ule anakufwa. |
|
2. Regime ya kutshangia bile wanandoa bana pata mu bukweri (communauté des biens réduits aux acquêts) : |
|
Mu iyi regime, banandoa beko naweka pamoya bintu bile bari pata mu ndoa (na ma ndeni ile bibi ao bwana aribeba). Ni kanuni ya kusaidiana mu ndoa). |
|
Faida: |
|
• Wakati wa kifo, ule ana bakiya ata beba kipande ya bintu pashipo kuripia. |
|
|
|
• Wakati yakwatshana, biko teke teke ku kabula bintu nju bintu biote bile biriuziwa mu ndoa ni bia kila muntu (kipande kipande). |
|
Bubaya: |
|
• Kama Bibi ao bwana eko na ndeni, mupinda ndeni anezi ku beba bintu bia mwenye ndeni ao bia mwingine. |
|
|
|
• Kama mumoja ana uzisha kintu kiake na anauza bintu bingine, bile bintu ni paka biake ye moya. Lakini, inafai ule mwenye kuzisha oneshe kwa ukweli kule kunatokea makuta; |
|
lakini bamingi abafwanyake vile. Vile, familia ya mwanandoa moya inezi kuogopa kumupa kintu nju kile kintu kishingie mu ile regime ya communautee. |
|
|
|
• Mu wakati ya kwatshana, ma account iko teke teke kufwanya lakini iyi oneshaketu kwa ukweli makuta ya kila muntu. |
|
|
|
• Kutshangia kwa bintu pamoya kunezi ku leta mambo nju ma decisions ya maana (kuzisha bintu, etc…) kunapashwa kufanishikwa paka na masikilizano ya ba banandoa bote bawiri. |
|
3. Regime ya communaute universelle: mu iyi regime bintu bile ba bibi na bwana baripata kabla ya ndoa na katika ndoa binawekwa pamoya pasipo kwangalia siku ile bariipata na mufano bariipata. |
|
Faida: |
|
• Ile regime iko na saidia kupitia conjoint (bibi ao bwana) bintu pasipo kuripa makuta ya succession. |
|
|
|
• Mu wakati ya kifo, batoto abataripa droit ya succession, paka ku lufu ya muzazi wa piri. |
|
Bubaya: |
|
• Batoto batapata abattement successoraux paka mala moya, |
|
|
|
• Ma ndeni anikwa ya bote bawiri ata kama ni moya ari kopa kabla ya ao mu ndoa, |
|
|
|
• Ma bintu ile banandoa bari pata mu ndoa inakwa yabo bote bawiri ila kama kuko musikilizano ingine mu contrat yabo ya ndoa. |
|
|
|
• Wakati ya kwatshana, bintu bita kaburiwa kipande kipande pashipo kwangaria kule biritokea ao namuna bariipata, |
|
|
|
• Risque ya bukonvi kama kuna kuya batoto ba kitanda kiakwanza.""" |
|
}, |
|
{ |
|
"role": "user", |
|
"content": transcribed_text |
|
}, |
|
], |
|
model="gpt-4" |
|
) |
|
return response.choices[0].message.content |
|
|
|
def inference(text): |
|
|
|
response = client.audio.speech.create( |
|
model="tts-1", |
|
voice="nova", |
|
input=text |
|
) |
|
output_file = "tts_output.mp3" |
|
response.stream_to_file(output_file) |
|
return output_file |
|
|
|
def process_audio_and_respond(audio): |
|
text = transcribe(audio) |
|
response_text = generate_response(text) |
|
output_file = inference(response_text) |
|
return response_text, output_file |
|
|
|
demo = gr.Interface( |
|
process_audio_and_respond, |
|
gr.inputs.Audio(source="microphone", type="filepath", label="Bonyeza kitufe cha kurekodi na uliza swali lako"), |
|
[gr.outputs.Textbox(label="Jibu (kwa njia ya maandishi)"), gr.outputs.Audio(type="filepath", label="Jibu kwa njia ya sauti (Bofya kusikiliza Jibu)")], |
|
description="Uliza Swali kuhusu haki and sheria za udongo", |
|
theme="compact", |
|
layout="vertical", |
|
allow_flagging=False, |
|
live=True, |
|
) |
|
|
|
demo.launch() |