File size: 9,908 Bytes
ad95864 3a022d6 3cd8c03 7c970f6 ad95864 ff52370 ad95864 7c970f6 6da0be1 ad95864 ff52370 ad95864 ff52370 ad95864 ff52370 ad95864 ff52370 ad95864 ff52370 ad95864 ff52370 ad95864 f54a7c1 ad95864 74bb2e1 ff52370 74bb2e1 3a022d6 74bb2e1 2f4b5ea ad95864 ff52370 f136dfc 74bb2e1 f136dfc 74bb2e1 f136dfc 74bb2e1 ad95864 74bb2e1 ff52370 ad95864 ff52370 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
import os
import openai
import gradio as gr
from transformers import pipeline
import tempfile
import requests
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(
model="gpt-4-1106-preview",
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
},
]
)
return response.choices[0].message.content
def inference(text):
response = client.audio.create(
model="tts-1-hd",
voice="alloy",
text=text
)
if hasattr(response, 'url'):
audio_url = response.url
return audio_url
else:
raise Exception("An error occurred: OpenAI did not return a valid response for the audio file.")
def process_audio_and_respond(audio):
text = transcribe(audio)
response_text = generate_response(text)
audio_url = inference(response_text)
response = requests.get(audio_url)
# Create temporary audio file
with tempfile.NamedTemporaryFile(suffix=".mp3", delete=False) as temp_file:
temp_file.write(response.content)
temp_filepath = temp_file.name
return response_text, temp_filepath
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() |